The year is expected to be picked as current year instead of the 00 year as shown below.
mysql> select str_to_date('Jul 15 12:12:51', '%b %e %T');
+--------------------------------------------+
| str_to_date('Jul 15 12:12:51', '%b %e %T') |
+--------------------------------------------+
| 0000-07-15 12:12:51 |
+--------------------------------------------+
Expected result:
| 2013-07-15 12:12:51 |
Well, that's intended. Quoting the doc:
Unspecified date or time parts have a value of 0, so incompletely specified values in str produce a result with some or all parts set to 0. [...] “Zero” dates or dates with part values of 0 are permitted unless the SQL mode is set to disallow such values.
It's easy to fix, btw:
select str_to_date(CONCAT(YEAR(NOW()), ' ', 'Jul 15 12:12:51'), '%Y %b %e %T');
-- July, 15 2013 12:12:51+0000
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments