Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP/MySQL Date Query



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

10+ Year Member


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.


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

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 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.



Featured Threads

Hot Threads This Week

Hot Threads This Month