I don't know how to do it with a DATE field, but with a DATETIME field you can query it like this:
Code:
SELECT field FROM table WHERE datetime_field >= ADDDATE(NOW(),INTERVAL -24 HOUR)
I like DATETIME fields because you might as well know the exact time, right? More data is better than less. And it lets you select records based on a time range, like the example above. You can change -24 HOUR to any number of hours or use DAY, MINUTE etc.
Edit: Also, MySQL stores the time in UTC time, so the time may not be the same as where you are. A little PHP can take care of that though, and make it display your local time.
Last edited by Phaedrus; 04-01-2005 at 08:27 PM..
|