如果不使用PHP,如何将这种格式"11/16/2002 12:00:00 PM
"更改为MySQL能够理解的内容?
我尝试过SELECT CONVERT('11/03/2002 02:45:33 PM', DATETIME) AS datetime;
,但为空
您可以使用STR_TO_DATE函数-
SELECT STR_TO_DATE('11/03/2002 02:45:33 PM', '%d/%m/%Y %h:%i:%s %p') AS dt;
+---------------------+
| dt |
+---------------------+
| 2002-03-11 14:45:33 |
+---------------------+
或
SELECT STR_TO_DATE('11/03/2002 02:45:33 PM', '%d/%m/%Y %r') AS dt;
+---------------------+
| dt |
+---------------------+
| 2002-03-11 14:45:33 |
+---------------------+