Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 datetime thing

Author  Topic 

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-27 : 03:55:18
hi my oracle one is like this

IF to_date(to_char(to_date(PCurrentDate,'mm-dd-yyyy hh24:mi:ss'),'mm-dd-yyyy'),'mm-dd-yyyy') >= to_date(PTemp1,'mm-dd-yyyy') Then

trying to write in sql server like this


IF datediff(Day,Convert(Datetime,@PCurrentDate, 120) > = convert(varchar(50),@PTemp1,108)

exception was

Conversion failed when converting the varchar value 'Jan 26 2010 12:00AM' to data type int.

can you give me the query for sql server please

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-27 : 04:05:52
Did you know datediff returns integer value?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-27 : 04:09:48
IF DATEDIFF(DAY, @pTemp1, @pCurrentDate) >= 0


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-27 : 04:10:05
yes please help me madhivanan to frame my query in sql server
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-27 : 04:16:23
Try

IF @pTemp1>=@pCurrentDate

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajasekhar857
Constraint Violating Yak Guru

396 Posts

Posted - 2010-01-27 : 04:18:25
THANKS
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-27 : 04:21:50
When you convert Oracle queries into SQL Server, try understand source code and convert

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -