sql-server - 当针对日期时间列查询少于 90 天时,如何“忽略”1/1/1753?
问题描述
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 子句消除了我需要查看的许多记录。
解决方案
作为绷带,您可以这样做(对于 1753,最好使用 NULL):
select case when [Estimated Return Date] > '17530101' AND
[Estimated Return Date] <= DATEDIFF(day, -90, GETDATE())
then '90 Days or Less To Estimated Return Date'
else '' end as [Alert], [No_]
from [Rental Header];
推荐阅读
- docker - 更改 Kubernetes 集群的主 IP 地址
- java - kotlin 中的数据绑定 TypeConverter 错误
- google-cloud-ml - 如何在 Cloud ML Engine 中为作业指定更多内存
- java - Collator - Android 和 Windows 中针对相同美国语言环境的不同排序规则
- python - python logging - “root”dict键有什么作用?
- extjs - ExtJs 在不同的浏览器上表现不同
- javascript - jQuery 删除/添加类只工作一次
- list - 在生成的数字在列表中时生成随机数 - ansible
- mysql - 在 EntityFrameworkCore 中加载相关数据时出错
- php - 如何检测此 CREATE TABLE SQL 括号之间的代码行?