質問

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