jim.davidson Posted August 27, 2010 Share Posted August 27, 2010 I have a timestamp field in my mySQL table and need to check if it's 14 day or older. What's the best way to do this? Any help will be appreciated Quote Link to comment Share on other sites More sharing options...
The Eagle Posted August 27, 2010 Share Posted August 27, 2010 Although I don't completely understand I've a brief idea of what you want to accomplish. $time = strtotime('$time'); $two_weeks_ago = strtotime('-2 week'); if( $time > $two_weeks_ago ) { echo ""; } else { echo ""; } Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted August 27, 2010 Share Posted August 27, 2010 Depends on what you mean by "check". Do you want to select records that are 14 days or older or not select records that are 14 days or older? This will do those: Older than 14 days: SELECT * FROM table_name WHERE ( TO_DAYS(CURDATE()) - TO_DAYS(column_name) ) > 14 Not older than 14 days: SELECT * FROM table_name WHERE ( TO_DAYS(CURDATE()) - TO_DAYS(column_name) ) <= 14 Quote Link to comment Share on other sites More sharing options...
jim.davidson Posted August 27, 2010 Author Share Posted August 27, 2010 Thank you, now that I see it it seems simple enough even for me. Again Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.