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
 General SQL Server Forums
 New to SQL Server Programming
 Date Current Week

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2012-03-29 : 14:41:09
Can anyone tell me why this statement is returning 13 for the current week when it should be 64 or 65??

select DATEPART(wk, GETDATE() - '2011-01-01') AS currentweek

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-03-29 : 14:46:21
Because GETDATE() - '2011-01-01' is March 30, 1901

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-03-29 : 14:47:26
select datediff(wk,'2011-01-01',GETDATE())

Will return 65

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -