>>>>> "Aldrian" == Aldrian Gintingsuka <aldrian@stripped>
Aldrian> I might be a little unclear about my problem. What I am confused about is why
Aldrian> the WEEK command returns 0 for Jan 1 of some years and returns 1 for some
Aldrian> other years.
Aldrian> WEEK('1997-01-01') => 1;
Aldrian> WEEK('1998-01-01') => 0;
Aldrian> I received a direct response from Piet Wesselman, and (with his his
Aldrian> permission) would like to share it here in the list.
>> On Mon, 26 Apr 1999, Piet Wesselman wrote:
pwessel> January 1 is only in week 1, if this week contains the first Thursday
pwessel> of the year (or January 4, which is the same). See the ISO 8601:1988
pwessel> standard for more information.
pwessel> Maybe this helps.
pwessel> Piet Wesselman
Aldrian> And after testing some other years, I think I begin to understand how it
Aldrian> Jan 1 is in week 1 if that week contains at least four days (more than the
Aldrian> number of days in the previous year's last week).
Aldrian> If Sunday is the 1st day of the week,
Aldrian> Jan 1 is in week 1 if it starts in (Sun, Mon, Tue, Wed)
Aldrian> If Monday is the 1st day of the week,
Aldrian> Jan 1 is in week 1 if it starts in (Mon, Tue, Wed, Thu)
Aldrian> Otherwise, it is in week 0 (continuation of the last week of the previous
Aldrian> Is that how weeks are calculated in MySQL???
Yes; When WEEK() returns a number in the range 1-52, it will always be
identical to the week number on your calendar. The week 0 is the last
week of the previous year. 53 is the first week of next year.