SQL Server 2005 日期时间(仅返回 hh:mm)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9482358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:35:05  来源:igfitidea点击:

SQL Server 2005 DateTime (return only hh:mm)

sqlsql-serversql-server-2005

提问by pikk

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

我正在研究一个返回DateTime数据类型列的存储过程。

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

但我只想立即返回hh:mm。我正在使用它,但它返回秒。

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

Any ideas to remove the seconds?

有什么想法可以删除秒吗?

回答by AdaTheDev

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

只需将其更改为转换为 VARCHAR(5) 即可:)

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

回答by Vikram

try this:

尝试这个:

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