> PHP handles this correctly -- if I do a date("W-y", $date) 
> for '2001-12-31'
> I get '01-02', but in mysql you get the wrong year:  '01-01'

I don't know where you got this data from, but the second number would be the year, 
that means mysql is showing the right year and php is showing the wrong year ( xx-01 
is right )
 
> Here's the an example (the second one is not what I'd expect):
> 
> SELECT DATE_FORMAT('2001-12-25', '%v-%y');
> +------------------------------------+
> | DATE_FORMAT('2001-12-25', '%v-%y') |
> +------------------------------------+
> | 52-01                                             |
> +------------------------------------+
> 
> SELECT DATE_FORMAT('2001-12-31', '%v-%y');
> +------------------------------------+
> | DATE_FORMAT('2001-12-31', '%v-%y') |
> +------------------------------------+
> | 01-01                                              |
> +------------------------------------+
> 
> SELECT DATE_FORMAT('2002-01-05', '%v-%y');
> +------------------------------------+
> | DATE_FORMAT('2002-01-05', '%v-%y') |
> +------------------------------------+
> | 01-02                                             |
> +------------------------------------+
> 
> I'm using mysql version 3.23.51-log, and I haven't seen anything with
> DATE_FORMAT in the changelog since.
> 
> Do people agree that this is a bug?
> Is there any work around for this?
 
from the documentation
%v  Week (01..53), where Monday is the first day of the week. Used with '%x'
should you be using %x with this?
%x  Year for the week, where Monday is the first day of the week, numeric, 4 digits, 
used with '%v'

Don't really know how you would use them with each other to get the right date, but 
you must be able to do it some way

%u  Week (00..53), where Monday is the first day of the week  
SELECT DATE_FORMAT('2001-12-31', '%u-%y');
+------------------------------------+
| DATE_FORMAT('2001-12-31', '%u-%y') |
+------------------------------------+
| 53-01                              |
+------------------------------------+

the note that the week can return 53, perhaps this is being retranslated into week 1 
when using %v

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to