您可以通过计算或格式化来解决此问题。我认为这个例子的格式化会更简单。尝试这个:
SELECT Convert(VarChar(20), DATEPART(HOUR,VC.INTERVAL)) + ':00' AS DATE
,DATEPART(HOUR,VC.INTERVAL) AS INTERVAL
FROM VMUK_Q1R_IB_CONSOLIDATED VC
如果您想显示完整的日期+时间,向下取整,试试这个:
SELECT Convert(VarChar(20), VC.Date, 101) + Convert(VarChar(20), DATEPART(HOUR,VC.INTERVAL)) + ':00' AS DATE
,DATEPART(HOUR,VC.INTERVAL) AS INTERVAL
FROM VMUK_Q1R_IB_CONSOLIDATED VC
如果你也想要时间范围,试试这个:
SELECT Convert(VarChar(20), VC.Date, 101) + Convert(VarChar(20), DATEPART(HOUR,VC.INTERVAL)) + ':00' AS DATE,
,DatePart(HOUR,VC.INTERVAL)) + ':00 - ' + DatePart(HOUR, DateAdd(HOUR, VC.INTERVAL, 1)) + ':00' AS TimeRange
,DATEPART(HOUR,VC.INTERVAL) AS INTERVAL
FROM VMUK_Q1R_IB_CONSOLIDATED VC