gpt4 book ai didi

mysql - SQL 时间 24 小时到 12 小时格式

转载 作者:行者123 更新时间:2023-11-29 04:39:31 24 4
gpt4 key购买 nike

我的 table 是这样的:

+----------------+------------+
| Date + Time |
|-----------------------------|
| 2015-09-23 | 17:20:25 |
| 2015-09-23 | 17:25:27 |
| 2015-09-24 | 06:29:27 |
-------------------------------

我只想获取时间列,并希望它以 12 小时格式显示。像这样:

5:20 P.M.
5:25 P.M.
6:29 A.M.

我使用了这个查询:SELECT time FROM attendance WHERE 1

最佳答案

试试这个(对于 MSSQL)

select CONVERT(varchar(15),Time,100) from attendance where 1

对于MySQL

select TIME_FORMAT(Time, '%r') from attendance where 1

关于mysql - SQL 时间 24 小时到 12 小时格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32757757/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com