把SQLServer 中日期处理与时间段处理记录下来
直接上代码
SELECT
dddd,
CAST(DATEDIFF(SECOND,'1970-01-01 00:00:00',DATEADD(MINUTE,s.number*1,@DECDT)) - 32400 AS BIGINT) * 1000 st,
CONVERT(VARCHAR(19),DATEADD(MINUTE,s.number*1,@DECDT),120) dt
FROM master..values s
WHERE s.type = 'P'
AND s.number < @DIFFMINUTE),zd AS (
SELECT dddd,vvvv,tttt
FROM XXXXXX
WHERE xxxx = @DEVICEID
AND date >= @DECDATE
AND date <= @LASTDECDATE