homepage Welcome to WebmasterWorld Guest from 54.161.174.246
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP/MySQL Date Query
sysdomatic

10+ Year Member



 
Msg#: 7393 posted 12:52 am on Mar 18, 2005 (gmt 0)

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

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



 
Msg#: 7393 posted 9:06 am on Mar 18, 2005 (gmt 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.

dc

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved