• Thanks for nice article.

    Also function which returns the Weeks is more usefull for retail programs and like-for-like discussions.

    As you now sql server's DATEPART weeknumber function does not return the real Week number according to the

    4-5-4 calendar...

    For example if your week starts with Monday.

    01/01/2010 Friday

    02/01/2010 Saturday

    03/01/2010 Sunday

    04/01/2010 Monday

    Sql Server returns 1 for weeknumber of 01/01/2010 but it is the 53th week of 2009.

    Sql Server returns 2 for weeknumber of 04/01/2010 but it is the 1st week of 2010.

    So the new function should return 2009W53 2010W01

    anyway thanks again 😉