我想发送或触发一封邮件,给定指定的日期超过24小时。
DATEADD(day, -1,Getdate()) or (now() +interval 1 day)
这些我已经使用过但无法看到预期的输出
我尝试了
select * from table where date >= DATEADD(day, -1,Getdate())
where date ex. 2018-11-05 00:30:27.863
您的查询需要<
符号而不是>
:
select * from table where date <= DATEADD(day, -1, Getdate())
因为您需要date
比Getdate() - 1 day
。
或:
select * from table where Getdate() >= DATEADD(day, 1, date)
您可以使用datediff((函数如下 -
select * from table where DATEDIFF(hh,dateColumn,GETDATE()) > 24