Forum Moderators: coopster

Message Too Old, No Replies

PHP/MySQL Date Query

         

sysdomatic

12:52 am on Mar 18, 2005 (gmt 0)

10+ Year Member



Hi,

If I have a table in my database full of messages, with dates such as "2003-12-12 10:30:29" (months and days both have trailing zeroes, and the time is in 24 hour format if that helps), then how do I go about constructing a query to only show messages that are less than 30 days old? Do I need to change the date into something else and then query MySQL? I'm stuck, thanks.

dreamcatcher

9:06 am on Mar 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mysql_query("SELECT * FROM table WHERE date > (CURDATE() - INTERVAL 30 DAYS)");

Think something like that should work ok. The other guys will be able to correct me, as I`m not 100% sure.

dc