is there a way to get all the week numbers by a given year?
Let's say I have the year 2011 and want all the weeks for that year, is this possible?
I am using Sql Server 2008.
Query:
SELECT DATEPART(wk,DATEADD(wk,t2.number,'2011')) as Weeknumb
FROM master..spt_values t2
WHERE t2.type = 'P'
AND t2.number <= 255
AND YEAR(DATEADD(wk,t2.number,'2011'))=2011
Week number according to the ISO-8601 standard, weeks starting on Monday. The first week of the year is the week that contains that year's first Thursday (='First 4-day week'). The highest week number in a year is either 52 or 53.
You can use SELECT DATEPART(WEEK,GETDATE())
to get the week number of the year, ideally i'd say you need a calendar lookup table to build from.