I'm trying to create a query that selects values that were inserted in today's date. The values are stored as raw dates in the following format: 2009-03-30 05:22:03 So far I've come up with the following but not sure how to progress? Where I'm not sure what's needed I've simply put it in words. mysql_query("SELECT count(id) FROM table WHERE UNIX_TIMESTAMP(time) = today"); PHP: Thanks in advance.
Assuming 'time' is your datestamp field in the format you quoted; mysql_query("SELECT count(id) FROM table WHERE date(time) = date(now())"); PHP:
Will the OP ever be able to select that ? The time will never match ? Wouldn't the OP need a Start date, time and an End date, time ? EDIT: Try something like this to start with and let us know the results: mysql_query("SELECT count(id) FROM table WHERE date(time) = date(NOW() - INTERVAL 1 DAY )"); PHP: or mysql_query("SELECT count(id) FROM table WHERE timestamp = (NOW() - INTERVAL 1 DAY )"); PHP: