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)

Junior Member

10+ Year Member

joined:Mar 30, 2003
votes: 0


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)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
votes: 0

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.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members