SQL Blog - Pieter van Maasdam, Macaw

SSIS, SSAS, SSRS & other SQL-things I come across...
SQL - Wrong results in Isoweek function
In our organisation we use the ISOweek function to determine weeknumbers for a given date. This function appears to be dependant of the language setting (@@DATEFIRST) on the SQL Server. For example: January 5, 2009 should return weeknumber 2, but since the language is set to us_english it returns weeknumber 1 for the given date. Since the weeknumber returned by this function is not correct, we needed another solution.
We found another sql-function that checks the DATEFIRST setting before it calculates the weeknumbers: 
This gave us the expected result.

Published Tuesday, February 24, 2009 1:25 PM by Repieter

Filed under:


No Comments