SQL - 昨天的日期 [英] SQL - Yesterday's date
本文介绍了SQL - 昨天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 SQL 查询:
I have an SQL query:
SELECT ....
WHERE CalendarDateTime.StartDate >= NOW()
如何将 NOW()
部分更改为昨天引用?
How can I change the NOW()
part to reference yesterday?
推荐答案
SELECT ....
WHERE CalendarDateTime.StartDate >= NOW() - INTERVAL 1 DAY
但我猜 StartDate
是一个 DATE,你真正想要的是包括今天的事件,你当前的解决方案只在午夜执行.在这种情况下,更合适的解决方案是:
But I guess StartDate
is a DATE and what you actually want is to include today's events, which your current solution does only at midnight. In that case the more appropriate solution is:
SELECT ....
WHERE CalendarDateTime.StartDate >= DATE(NOW())
这篇关于SQL - 昨天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文