MySQL Return Today's Records Using DATE from DATETIME Field

date, datetime, mysql, sql, where-clause

Solution

If there in no future date in `occurred`, you could just use below:

SELECT * FROM `actions` WHERE `occurred` > DATE_SUB(CURDATE(), INTERVAL 1 DAY);

Problem

I have a table called "actions" with a `DATETIME` column called "occurred". I'm trying to return the records for today by doing the following ``` SELECT * FROM `actions` WHERE `occurred` = DATE(NOW()); ``` But I get an empty result set. If I take the `WHERE` clause out, I can see all 295 rows in the table and there's at least 30 rows from today. Later I will be writing another query to return all records between today's date and X amount of days in the past but before I can get there I need to know why this query is returning an empty result set. Thanks in advance.

Original source