SQL Blog - Pieter van Maasdam, Macaw

SSIS, SSAS, SSRS & other SQL-things I come across...
SQL2008 - IsoWeek in Datepart function

To calculate the correct weeknumber I always used the IsoWeek function (found here: http://msdn.microsoft.com/en-us/library/aa258261(SQL.80).aspx).

In SQL 2008 this function is available in the DATEPART function:

SELECT DATEPART(wk, '4 jan 2009') AS WeekNumber, DATEPART(isowk, '4 jan 2009') AS IsoWeekNumber

Output:

WeekNumber IsoWeekNumber
2 1

Published 24 February 2009 08:01 by Repieter

Filed under:

Comments

# SQL - Wrong results in Isoweek function@ 24 February 2009 12:45

See my previous post ( sqlblogcasts.com/.../sql2008-isoweek-in-datepart

SQL Blog - Pieter van Maasdam, Macaw