如何找到给定的任何日期(Ex.2018-11-0500:30:27.863)大于24小时,或者从SQL Server的该



我想发送或触发一封邮件,给定指定的日期超过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())

因为您需要dateGetdate() - 1 day
或:

select * from table where Getdate() >= DATEADD(day, 1, date)

您可以使用datediff((函数如下 -

select * from table where DATEDIFF(hh,dateColumn,GETDATE()) > 24 

最新更新