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
 datepart week doesn't return existing format

Author  Topic 

pavlos
Yak Posting Veteran

59 Posts

Posted - 2012-01-22 : 22:47:21
hey all..
i use the following to retrieve the week

SELECT DATEPART(WW, H.FINISHDATETIME)) as 'WEEK'

query works fine but doesn't match my existing format.

my current format returns dates as follows
31st dec 2011 = WEEK 52
1st jan 2012 = WEEK 52
2nd jan 2012 = WEEK 1
9th jan 2012 = WEEK 2

but SELECT DATEPART(WW, H.FINISHDATETIME)) as 'WEEK'
returns the following
31st dec 2011 = WEEK 53
1st jan 2012 = WEEK 53
2nd jan 2012 = WEEK 53
9th jan 2012 = WEEK 1

any ideas on how to change the format?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-01-23 : 11:54:25
Are you runnig in 2 different environments? Is it possible that the DATEFIRST value is different? This is also affected by the LANGUAGE settings. You could check with
SELECT @@DATEFIRST
Go to Top of Page
   

- Advertisement -