>>>>> "Benjamin" == Benjamin Pflugmann <philemon@stripped> writes:
Benjamin> What you describe is the expected behaviour. You are right, that
Benjamin> 2005-01-01 belongs to week 53 of the year 2004 according to ISO
Benjamin> standard. The problem is, that 2005-12-31 also belongs to week 53 -
Benjamin> but of year 2005.
Benjamin> Since this would give quite weird results if you want to order by week
Benjamin> or make similar calculations, week() does *not* return strictly ISO
Benjamin> weeks. If you want to return ISO weeks, you would have to return also
Benjamin> the year to make the result unambigious.
Benjamin> There was already a discussion about this some time ago (from which I
Benjamin> lend most of my explanation). You might want to check it out in the
Benjamin> list archives.
Benjamin> On Tue, Dec 14, 1999 at 12:42:21AM +0100, jorgen@stripped wrote:
>> There seems to be a bug in the WEEK() function. When the first day of
>> the year is a Friday, Saturday or Sunday (i.e that week belongs to the
>> previous year), the WEEK() function reports week=0 for all those dates
>> before the date when WEEK() function (correctly) reports week=1.
>> It should report Week=53 upto 2010-01-03.
>> I tested all dates from 1999-12-25 and 12700 days forward, and grep'ed out
>> all reports of Week=0, here's the result of that:
>> Date=2005-01-01 Week=0 Weekday=5
>> Date=2005-01-02 Week=0 Weekday=6
>> Date=2006-01-01 Week=0 Weekday=6
In MySQL 3.23.8 we have added a new yearweek() function that works
as you would want it to work :)