Just find the first Monday on or after the start of the RedFriday period, and use datediff to calculate the week number:select RedFridayWeekNumber = (datediff(dd,,@FirstMondayofRedFriday,getdate())/7)+1
-- Find first Monday on or after a given dateselect a.DT, FirstMondayMethod1 = --Function F_START_OF_WEEK here: --http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47307 dbo.F_START_OF_WEEK(dateadd(dd,6,a.DT),2), FirstMondayMethod2 = dateadd(dd,(datediff(dd,-53690,dateadd(dd,6,a.DT))/7)*7,-53690)from ( --Test Dates select DT=convert(datetime,'20080905') union all select DT=convert(datetime,'20080906') union all select DT=convert(datetime,'20080907') union all select DT=convert(datetime,'20080908') union all select DT=convert(datetime,'20080909') union all select DT=convert(datetime,'20080910') union all select DT=convert(datetime,'20080911') union all select DT=convert(datetime,'20080912') ) aorder by a.DTResults:DT FirstMondayMethod1 FirstMondayMethod2----------------------- ----------------------- -----------------------2008-09-05 00:00:00.000 2008-09-08 00:00:00.000 2008-09-08 00:00:00.0002008-09-06 00:00:00.000 2008-09-08 00:00:00.000 2008-09-08 00:00:00.0002008-09-07 00:00:00.000 2008-09-08 00:00:00.000 2008-09-08 00:00:00.0002008-09-08 00:00:00.000 2008-09-08 00:00:00.000 2008-09-08 00:00:00.0002008-09-09 00:00:00.000 2008-09-15 00:00:00.000 2008-09-15 00:00:00.0002008-09-10 00:00:00.000 2008-09-15 00:00:00.000 2008-09-15 00:00:00.0002008-09-11 00:00:00.000 2008-09-15 00:00:00.000 2008-09-15 00:00:00.0002008-09-12 00:00:00.000 2008-09-15 00:00:00.000 2008-09-15 00:00:00.000(8 row(s) affected)
CODO ERGO SUM