SQL Server 2005 DateTime (return only hh:mm)

江枫思渺然 提交于 2019-12-30 06:51:08

问题


I am working on a stored procedure which returns a column of DateTime datatype.

But I want to return only hh:mm with no seconds. I am using this but it returns seconds.

 CONVERT(VARCHAR(8), tbltime.Time, 108) AS [Time]

Any ideas to remove the seconds?


回答1:


Just change it to convert to VARCHAR(5) instead :)

CONVERT(VARCHAR(5),tbltime.Time,108) AS [Time]



回答2:


try this:

select left(CONVERT(VARCHAR(8),getdate(),108),5)


来源:https://stackoverflow.com/questions/9482358/sql-server-2005-datetime-return-only-hhmm

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