0

I have an SQL query:

SELECT ....
WHERE CalendarDateTime.StartDate >= NOW()

How can I change the NOW() part to reference yesterday?

Fraser
  • 14,036
  • 22
  • 73
  • 118
  • Try the solution in this question, but with a minus operator. http://stackoverflow.com/questions/3887509/mysqls-now-1-day – Nick Vaccaro Nov 19 '12 at 22:13
  • possible duplicate of [How to get today's / yesterday's data from MySQL database?](http://stackoverflow.com/questions/12551883/how-to-get-todays-yesterdays-data-from-mysql-database) – Leigh Nov 20 '12 at 18:16

1 Answers1

6
SELECT ....
WHERE CalendarDateTime.StartDate >= NOW() - INTERVAL 1 DAY

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())
AndreKR
  • 32,613
  • 18
  • 106
  • 168
  • 1
    This seems to be from Silverstripe Event Calendar where StartDate seems to be a Date, so see my revised answer. – AndreKR Nov 19 '12 at 22:33