我需要从SQL Server中的表中获取时间

时间:2012-02-11 11:29:44

标签: sql sql-server sql-server-2008 tsql

AS

SELECT     TOP 50 *
FROM         dbo.Ritten

WHERE     (Status = 0)and (Afgemeld = 0)

ORDER BY CAST(Datum AS date),Tijd

输出= 13:30:00.0000000

我需要这个= 13:30

3 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

SELECT CONVERT(CHAR(5), Datum, 8)
  FROM Tijd;

答案 2 :(得分:0)

您不需要Seconds值吗?

SELECT convert(varchar(15), getdate(), 114) 
-- (will return HH:mm:ss:mmm format [24 hr])

所以在您的查询中:

SELECT SUBSTRING(convert(varchar(15), CAST(Datum as DateTime), 114),1,5) as DateString
-- this will return HH:mm format

T-SQL Date Format