问题
I am using sql server 2005. I just want to know is there something we can get the week number for the particular month. Example Date = '2008-10-16' Is there something we can have SELECT WEEK(Date). Or any better suggestion.
回答1:
select (datepart(dd,'2008-10-08')-1) / 7 + 1
回答2:
You can do it this way:
SET @weeksinmonth=datediff(week, @date, @lastdate) + 1
That is a copy-and-paste out of one of my stored procedures.
回答3:
SELECT DATEPART( week, '2008-10-16')
来源:https://stackoverflow.com/questions/203118/week-function-in-sql-script