mysql把字符串轉成時間格式的示例:
假如查詢demo表的數據為:
+------------------+| DueDate |
+------------------+
| 11/02/2019 10:35 |
| 21/12/2018 12:01 |
+------------------+
2 rows in set (0.00 sec)
將表中字符串轉成時間格式的語法:
select demo(DueDate,'%d/%m/%Y %h:%i %p') as ConvertDate from DemoTable;
得到結果:
+---------------------+| ConvertDate |
+---------------------+
| 2019-02-11 10:35:00 |
| 2018-12-21 00:01:00 |
+---------------------+
2 rows in set (0.00 sec)