您的位置:宽带测速网 > 网络知识 > mysql怎么把字符串转成时间格式

mysql怎么把字符串转成时间格式

2025-06-17 10:13来源:互联网 [ ]

mysql把字符串转成时间格式的示例:

假如查询demo表的数据为:

+------------------+

|DueDate|

+------------------+

|11/02/201910:35|

|21/12/201812:01|

+------------------+

2rowsinset(0.00sec)

将表中字符串转成时间格式的语法:

selectdemo(DueDate,'%d/%m/%Y%h:%i%p')asConvertDatefromDemoTable;

得到结果:

+---------------------+

|ConvertDate|

+---------------------+

|2019-02-1110:35:00|

|2018-12-2100:01:00|

+---------------------+

2rowsinset(0.00sec)