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)
 date format problem:- Need help ASAP

Author  Topic 

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2011-01-24 : 09:08:30
I have a sql server Job executing the Store procedure
containg below code

DECLARE @LastSunday DateTime
select @LastSunday = Convert(varchar(10),DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 6),120)

job fail to execuete giving error

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value

but the same store procedure works fin when executed in query analyser

I guess this could be bacause of the server date format might be different then the code?



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-24 : 09:10:57
DECLARE @LastSunday DateTime
select @LastSunday = DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 6)
select @LastSunday

Madhivanan

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

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2011-01-24 : 09:33:33
Thanks, I it is working under job now
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-24 : 09:47:38
quote:
Originally posted by chetanb3

Thanks, I it is working under job now


You are welcome

Madhivanan

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

- Advertisement -