我正在使用下面的查询,其中原始转换是为具有不同日期值的另一个表编写的。 [YMDRCVD]值为(INT,null)。我正在使用SQL管理工作室14并接收将表达式转换为数据类型日期时间错误消息的算术溢出错误。
SELECT
Year(CH.[YMDRCVD]) as [Receipt date Year],
Month(CH.[YMDRCVD]) as [Receipt Date Month],
COUNT(*) as [Count of Claims],
AVG(convert(numeric(19,2), DATEDIFF(day, CH.[YMDRCVD], CH.[YMDTRANS]))) as [Average Days from Receipt to Initial Finalized] ,
SUM(
CASE WHEN DATEDIFF(day, CH.[YMDRCVD], CH.[YMDTRANS]) > 10 THEN 1
ELSE 0
END) as [Count Processed in > 10 Days]
FROM [SERVICE_X] CH WITH (NOLOCK)
WHERE
CH.[YMDRCVD] >= '1/1/2016'
AND CH.[YMDRCVD] < '6/1/2016'
AND DATEDIFF(day, CH.[YMDRCVD], CH.[YMDTRANS]) < 20
AND DATEDIFF(day, CH.[YMDRCVD], CH.[YMDTRANS]) >= 0
GROUP BY Year(CH.[YMDRCVD]),
Month(CH.[YMDRCVD])
ORDER BY
Year(CH.[YMDRCVD]),
Month(CH.[YMDRCVD])
答案 0 :(得分:0)
答案 1 :(得分:0)
使用以下内容解码日期:
YYYYMMDD
:
DATEFROMPARTS( FLOOR([YMDRCVD]/10000), FLOOR([YMDRCVD]/100)%100, [YMDRCVD]%100 )