1

I would like the below select statement to be show as time rather than datetime. I'm aware that a cast as solution is likely however given I am trying to Cast as a "grouped by time", I am not finding a solution.

SELECT 
DATEADD(hour, DATEDIFF(hour, 0,dbo.tbReceiptLine.Time), 0) AS Hourly, 
DATEADD(minute, DATEDIFF(minute, 0, dbo.tbReceiptLine.Time) / 30 * 30, 0) AS [30 Mins]

I would like to show this as time only.

4

1 回答 1

0

在 SQL Server 2008 及更高版本中,您可以转换为time数据类型:

SELECT CAST(dbo.tbReceiptLine.Time as time)

请参阅日期时间数据类型的终极指南

于 2013-08-14T07:21:45.463 回答