Bug #68865 | STR_TO_DATE with %Y does not appear to work as documented | ||
---|---|---|---|
Submitted: | 4 Apr 2013 12:17 | Modified: | 20 Apr 2013 19:25 |
Reporter: | Yoseph Phillips | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Data Types | Severity: | S3 (Non-critical) |
Version: | 5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[4 Apr 2013 12:17]
Yoseph Phillips
[20 Apr 2013 19:25]
MySQL Verification Team
mysql is assuming the year is really 2021 in this case. mysql> SELECT DATE_FORMAT(STR_TO_DATE('21/06/20', '%Y/%m/%d'), '%Y/%m/%d'); +--------------------------------------------------------------+ | DATE_FORMAT(STR_TO_DATE('21/06/20', '%Y/%m/%d'), '%Y/%m/%d') | +--------------------------------------------------------------+ | 2021/06/20 | +--------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT DATE_FORMAT(STR_TO_DATE('21/06/20', '%y/%m/%d'), '%y/%m/%d'); +--------------------------------------------------------------+ | DATE_FORMAT(STR_TO_DATE('21/06/20', '%y/%m/%d'), '%y/%m/%d') | +--------------------------------------------------------------+ | 21/06/20 | +--------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select version(); +--------------+ | version() | +--------------+ | 5.6.12-debug | +--------------+ 1 row in set (0.00 sec) http://dev.mysql.com/doc/refman/5.6/en/two-digit-years.html Maybe it should return NULL with a warning if you forget to give a four digit date to %Y.