Bug #6132 STR_TO_DATE with %X,%V,%x,%v doesn't work
Submitted: 16 Oct 2004 22:18 Modified: 29 Apr 2005 15:48
Reporter: Clint Priest Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.5-gamma OS:Linux (Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[16 Oct 2004 22:18] Clint Priest
Description:
STR_TO_DATE with %X,%V,%x,%v doesn't work

How to repeat:
SELECT STR_TO_DATE(DATE_FORMAT(NOW(), '%X%V'), '%X%V') AS Output
Yields: 0000-00-00

Suggested fix:
n/a

Reference BugFix: #4756 which indicates support for %X,%V,%x,%v was added
[18 Oct 2004 6:57] Alexander Keremidarski
mysql> SELECT DATE_FORMAT(NOW(), '%X%V') AS d1, STR_TO_DATE(DATE_FORMAT(NOW(), '%X%V'), '%X%V') AS d2;
+--------+------------+
| d1     | d2         |
+--------+------------+
| 200442 | 0000-00-00 |
+--------+------------+
[29 Apr 2005 15:48] Michael Widenius
We will not fix this as year-week can't uniquely identify a date.

I added the following to the MySQL manual to clarify this:

Note that you can't use format "%X%V" to convert a year-week
string to date as a year-week doesn't uniquely identify a year-month if the
week crosses a month boundary.  If you want to convert a year-week to a date
you can do it by also specifying the week day:

mysql> select str_to_date('200442 Monday', '%X%V %W');
-> 2004-10-18