CASE
WHEN CAST([SYS_Created_On] as time) >= CAST('16:00' as time)
THEN DATEADD(dd, 1, CAST([SYS_Created_On] AS DATE))
ELSE CAST([SYS_Created_On] AS DATE)
END AS [Reported Date],
CASE
WHEN CAST([resolved_at] as time) >= CAST('16:00' as time)
THEN DATEADD(dd, 1, AS([resolved_at] AS DATE))
ELSE CAST([resolved_at] AS DATE)
END AS [Resolved Date]
我每天下午4点以后得到周一到周五的数据。如果报告日期是4点以后的星期五,或者报告日期是星期一的星期六或星期天,有人能帮我把它编码成这样吗。
1条答案
按热度按时间km0tfn4u1#
如果我理解正确,你需要有一个报告日期为下周一,如果收到的数据和时间是下午4:00之后,或
SYS_Created_On
是星期六还是星期天你需要得到与星期一对应的日期虽然有不同的方式更优雅(从代码较少的意义上说),但下面的描述更具描述性。