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 function

Author  Topic 

PeeJay2583
Starting Member

40 Posts

Posted - 2011-06-07 : 02:52:36
I have a Date Column in a table1 as below

2010-05-10 00:00:00.000
2010-07-22 00:00:00.000
2010-07-26 00:00:00.000
2010-10-13 00:00:00.000
2010-10-13 00:00:00.000

I want to use datepart function to get the week number
SELECT DATEPART([DATE],'WW') AS DATE_NEW FROM Table1

Getting an error message as below

Msg 155, Level 15, State 1, Line 1
'DATE' is not a recognized datepart option.

Please suggest.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-06-07 : 03:29:12
Read Books Online, the SQL Server help file.

SELECT DATEPART(WEEK, [Date]) FROM dbo.Table1



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

- Advertisement -