the year expected picked current year instead of 00 year 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 doc:
unspecified date or time parts have value of 0, incompletely specified values in str produce result or parts set 0. [...] “zero” dates or dates part values of 0 permitted unless sql mode set disallow such values.
it's easy 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
Comments
Post a Comment