>> 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 )

Sorry I was incorrect on PHP:  <?php echo date("W-y",  strtotime('2001-12-31
01:00:00'));?> prints 53-01.

I don't agree that mysql is 'right' here though, I realize that if you
simply strip out the year for the date it would be '01',  but if you wrap
the week number, you shouldn't you increment the year as well?     SELECT
DATE_FORMAT('2001-12-31', '%v-%y'); returning '01-01' is inaccurate to say
the least.

%x and %X have the same problem as %v (since they use it).

>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

This output makes sense and matches PHP's output so I'll use this instead.

Thanks,

Joe


---------------------------------------------------------------------
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