List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:April 25 1999 6:02pm
Subject:Week in year before 1998 starts from 1 instead of 0
View as plain text  
>>>>> "aldrian" == aldrian  <aldrian@stripped>
> writes:

>> Description:
aldrian> 	Bug in WEEK command??
>> How-To-Repeat:

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

mysql> select week('1997-12-31');     
aldrian> +--------------------+
aldrian> | week('1997-12-31') |
aldrian> +--------------------+
aldrian> |                 53 |
aldrian> +--------------------+
aldrian> 1 row in set (0.00 sec)

mysql> select week('1998-01-01'); 
aldrian> +--------------------+
aldrian> | week('1998-01-01') |
aldrian> +--------------------+
aldrian> |                  0 |
aldrian> +--------------------+
aldrian> 1 row in set (0.01 sec)

mysql> select week('1998-12-31');     
aldrian> +--------------------+
aldrian> | week('1998-12-31') |
aldrian> +--------------------+
aldrian> |                 52 |
aldrian> +--------------------+
aldrian> 1 row in set (0.01 sec)

Hi!

The above is actually correct!

1998-01-01 is week 53 of 1997.  Instead of returning 53, we thought it 
would be better to return 0, as 53 could easily be confused with the
last week of the year.

The only 'right' solution would be if WEEK() returned the week in format:

YYYY-WW

but this would break ODBC applications.

(Sorry, but for the moment I can't check what other SQL servers
returns in this case)


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