Jump to content

date grab help?


elis

Recommended Posts

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?

 

 

Link to comment
https://forums.phpfreaks.com/topic/77479-date-grab-help/
Share on other sites

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?

 

Link to comment
https://forums.phpfreaks.com/topic/77479-date-grab-help/#findComment-392256
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/77479-date-grab-help/#findComment-392264
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.