SQL Format Time Object From 24 Hour to 12

試著忘記壹切 提交于 2019-12-20 03:04:22

问题


Is there a way to convert a time object to a 12 hour format in SQL? I can't nessessarilly use datetime because the data being retrieved is not specific for dates.

16:45:00 --> 4:45 PM


回答1:


Try using this:

DECLARE @aux NVARCHAR(8)='16:45:00'
SELECT CONVERT(VARCHAR(15),CAST(@aux AS TIME),100)


来源:https://stackoverflow.com/questions/11745958/sql-format-time-object-from-24-hour-to-12

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!