Incorrect datetime value for function str_to_date
I can't see what is wrong with this:
mysql> select str_to_date('3/8/2010 12:31:00 AM', '%c/%e/%Y %k:%i:%s %p');
+-------------------------------------------------------------+
| str_to_date('3/8/2010 12:31:00 AM', '%c/%e/%Y %k:%i:%s %p') |
+-------------------------------------------------------------+
| NULL |
+-------------------------------------------------------------+
1 开发者_如何学编程row in set, 1 warning (0.00 sec)
mysql> show warnings;
+-------+------+---------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+---------------------------------------------------------------------------+
| Error | 1411 | Incorrect datetime value: '3/8/2010 12:31:00 AM' for function str_to_date |
+-------+------+---------------------------------------------------------------------------+
1 row in set (0.00 sec)
%k:%i:%s %p
%k
is 24-hour clock, doesn't work with %p
(AM/PM). Use %l
.
Try:
mysql> select str_to_date('3/8/2010 12:31:00 AM', '%m/%d/%Y %h:%i:%s %k');
精彩评论