我正在使用SQL Server 2008 R2。我需要得到星期日weekno,並且我已經有了查詢,但它顯示了錯誤的數據。我能做什麼 ?我想要獲得星期日WeekNo?
它顯示了2而不是1。例如,06-JAN-2013(WeekNo - 1)
我的查詢是
SELECT DATEPART (week, '01-13-2013 23:59:59.000') As WeekNo1 ,
DATEPART (week, '01-06-2013 23:59:59.000') As WeekNo2 ,
DATEPART (week, '12-30-2012 23:59:59.000') As WeekNo3 ,
DATEPART (week, '12-23-2012 23:59:59.000') As WeekNo4 ,
DATEPART (week, '12-16-2012 23:59:59.000') As WeekNo5 ,
DATEPART (week, '12-09-2012 23:59:59.000') As WeekNo6
初始/原始'DATEFIRST'設置應該在'SELECT ...'後恢復。 –
感謝您的回覆@justin,我接受你的回答.. –