I've got the problem that
select datepart(ww, '20100208')
is returning as result week 7 in SQL Server 2000. But 08.02.2010 should be week 6 according to the ISO 8601 specification! This is causing problems in delivery week calculations.
What should I do to get week number values according to ISO 8601?
One easy way to do this is to use
isowk
instead ofwk
as shown here:Like @MicSim and @AdaTheDev mentioned, this will only work in newer versions (>=2008).
You can do this within SQL 2008 very easily as it now supports isoww as the first datepart argument. However, this wasn't in SQL 2000 (or 2005). There is a function in this article which will do it for you in SQL 2000/2005.
In case the blog goes offline, here is the function. Go to the post to learn more about ISO and non-ISO weeks.