当对日期时间列查询少于90天时,如何“忽略” 1/1/1753?

时间:2018-08-09 15:05:57

标签: sql-server datetime datediff

select case when [Estimated Return Date] <= DATEDIFF(day, -90, GETDATE()) then 
'90 Days or Less To Estimated Return Date' else '' end as 'Alert', [No_]

from [Rental Header]
where [Estimated Return Date] != '1/1/1753'

问题在于它通过添加where子句消除了我需要查看的许多记录。

1 个答案:

答案 0 :(得分:3)

作为绷带,您可以这样做(最好将NULL用于1753):

hKW