I'm a little bored at work so I just compiled something more or less on the fly. Don't know why my datepart(wk, ...) reports the wrong weeknumber...and I haven't checked it all too much for the quality but I guess it might point you in the right direction.--> Setting saturday as the starting day of the weekSET DATEFIRST 6DECLARE @table table ( WeekNo int, MonthNo int, WeekStartDate datetime, WeekEndDate datetime, FinancialYear int )DECLARE @WeekStartDate datetime, @WeekEndDate datetime SET @WeekStartDate = '2009-01-04'SET @WeekEndDate = '2009-01-10'WHILE YEAR(@WeekStartDate) <= 2011 BEGIN INSERT INTO @table SELECT DATEPART(wk, @WeekStartDate)-1, DATEPART(mm, @WeekStartDate), @WeekStartDate, @WeekEndDate, YEAR(@WeekStartDate) SET @WeekStartDate = DATEADD(dd, 7, @WeekStartDate) SET @WeekEndDate = DATEADD(dd, 7, @WeekEndDate) END SELECT TOP 200 * FROM @table
- Lumbago