elis Posted November 15, 2007 Share Posted November 15, 2007 I want a script to run and only pull data that was updated in the last seven days based on the date attached to the field. Here's my script so far $query="select *,DATE_FORMAT(date, '%M %d, %Y') AS updated from member_entries where validated > 0"; $showresult = mysql_query($query) if(!$showresult) { usererror();} I don't know how to pull data that was updated within the last seven days based on $query[updated] field. I tried using MKtime() but that seems as if it's based on today and I want it to based on the last designated pull day (ie last Sunday) so that it's not reupdating each day and only once a week. Would this work better as a cron? Quote Link to comment Share on other sites More sharing options...
elis Posted November 15, 2007 Author Share Posted November 15, 2007 I've edited the code since and have changed my concept to something much easier, but still need help. Let's say I have two date-based variables: $updatedon and $lastvalidate What I have in mind is comparing the two dates like: if ($updatedon > $lastvalidate) { //positive handle } else { //negative handle } But I want to add seven additional days to whatever the $lastvalidate field brings. How would I do that? Quote Link to comment Share on other sites More sharing options...
obsidian Posted November 15, 2007 Share Posted November 15, 2007 I would try something like this (assuming you are storing "last_validated" and "updated_on" columns: SELECT * FROM member_entries WHERE last_validated > updated_on AND updated_on >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) Check out the MySQL Date and Time functions for more on what calculations are available. 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.