- Monday is the first day of a week ( a week is from mon - sun)
- Even if 1st January was a Sunday, the week 26 Dec - 01 Jan would be called week 1 (and not week 53).
For sybase this was pretty simple (since the server was configured to use ISO 8601). This pretty much explains itself:
select datepart(cwk, convert(datetime,'2009/01/03',111)) as thisyear
, datepart(cwk, convert(datetime,'2008/12/28',111)) as lastyearlastweeklastday
, datepart(cwk, convert(datetime,'2008/12/29',111)) as thisyearfirstweekfirstday
This returns 1,52,1.
Enjoy:)
No comments:
Post a Comment