List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:April 26 1999 9:16am
Subject:Re: Week in year before 1998 starts from 1 instead of 0
View as plain text  
>>>>> "Aldrian" == Aldrian Gintingsuka <aldrian@stripped>
> writes:

Aldrian> Thanks for the reply. I would expect the same situation for 1996 and 1997.
Aldrian> However, mysql returns 1, instead of 0, for the first day of 1997.

mysql> select week('1996-01-01');
Aldrian> +--------------------+
Aldrian> | week('1996-01-01') |
Aldrian> +--------------------+
Aldrian> |                  1 |
Aldrian> +--------------------+
Aldrian> 1 row in set (0.00 sec)

mysql> select week('1996-12-31');     
Aldrian> +--------------------+
Aldrian> | week('1996-12-31') |
Aldrian> +--------------------+
Aldrian> |                 53 |
Aldrian> +--------------------+
Aldrian> 1 row in set (0.01 sec)

mysql> select week('1997-01-01');       
Aldrian> +--------------------+
Aldrian> | week('1997-01-01') |
Aldrian> +--------------------+
Aldrian> |                  1 |
Aldrian> +--------------------+
Aldrian> 1 row in set (0.00 sec)


This is also ok. 1997.01.01 is on the first week of 1997 (check your
calender).  I don't think that WEEK('1997-12-31') should return 1
because this would also be very confusing and could lead to much
bigger problems than '53' when you present things for example with
GROUP BY..

The only 'right' thing that I can think of, would be to introduce a
'full_week()' function that returned the week in the 'YYYY-WW' format.

Regards,
Monty
Thread
Week in year before 1998 starts from 1 instead of 0aldrian23 Apr
  • Week in year before 1998 starts from 1 instead of 0Michael Widenius26 Apr
    • Re: Week in year before 1998 starts from 1 instead of 0Aldrian Gintingsuka26 Apr
      • Re: Week in year before 1998 starts from 1 instead of 0Michael Widenius27 Apr
        • Re: Week in year before 1998 starts from 1 instead of 0Aldrian Gintingsuka27 Apr
          • Re: Week in year before 1998 starts from 1 instead of 0Michael Widenius27 Apr