温馨提示×

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

小新
190
2021-02-02 17:04:59
栏目: 云计算
亿速云mysql数据库,读写分离,安全稳定,弹性扩容,低至0.3元/天!! 点击查看>>

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

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)

亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>

推荐阅读:hive怎么将字符串转成日期格式

0