SQLServer 中日期处理与时间段处理

时间:2022-06-24 20:11:17

把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
借助了功能表master..values。

相关文章