views:

670

answers:

2

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?

+3  A: 

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.

AdaTheDev
+1 for mentioning my blog post :-)
SQLMenace
Good blog post, indeed. :-) So there is no other way of getting the ISO week number in SQL Server 2000, except by using a UDF?
MicSim
@MicSim, unfortunately not. There is an argument to say don't do it in SQL Server, but return the data as-is and let your calling code work determine the week number. But that really depends on exact requirements so may or may not be worth you considering.
AdaTheDev
A: 

Hi, take a look at this link at the bottom you will find what you need http://msdn.microsoft.com/en-us/library/ms174420.aspx

IordanTanev
That relates to SQL 2008
AdaTheDev