문제

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.

도움이 되었습니까?

해결책

In SQL Server 2008 onwards you can cast to time datatype:

SELECT CAST(dbo.tbReceiptLine.Time as time)

See The ultimate guide to the datetime datatypes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top