Question : datetime to ISOweek & ISOyear

Hi,

I need a UDF (let's call it ISOyyyyww)  which requires a datetime input and returns a varchar(6) consisting of the ISOyear(as yyyy) concatenated with the ISOweek (as ww) according to the ISO 8601 standard. In BOL is an example for the ISOweek, but that doesn't include the year.

example

select dbo.ISOyyyyww('20031229')
should return : '200401'

select dbo.ISOyyyyww('20040125')
should return: '200404'

select dbo.ISOyyyyww('20000101')
should return: '199952'

I have made the function myself a while back, but it's monday morning and I can't remember where I put it and I don't want to make it again ;-)

If the solution works with every @@DATEFIRST setting it would be great!

Answer : datetime to ISOweek & ISOyear

Closed, 125 points refunded.
CetusMOD
Community Support Moderator
Random Solutions  
 
programming4us programming4us