Invalid date and time value for str_to_date function

I do not 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)
+5
source share
2 answers
%k:%i:%s %p

%k- 24-hour mode, does not work with %p(AM / PM). Use %l.

+7
source

Try:

mysql> select str_to_date('3/8/2010 12:31:00 AM', '%m/%d/%Y %h:%i:%s %k');
0
source

All Articles