Hi,
I have a table that holds a date field, I am wanting to have a script that checks the table for dates that are more than 11 months old, and have it email the data of any matching records.
This will run as a cron job.
I not sure where to start on checking the date field for dates older than 11 months .. any help would be appreciated.
Thanks
check db records for dates 11 months or older
Moderator: General Moderators
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
Is it something like:
I see example using:
Im assume date_sub is replaced with the field you are quering from the database?
Thanks
Code: Select all
$sql = mysql_query("SELECT * FROM table WHERE datefield(curdate(), INTERVAL 11 MONTH)");I see example using:
Code: Select all
date_sub(curdate(), INTERVAL 11 MONTH)Thanks
That would mean: there's a function datefield and it takes two parameters, a date and ....what is interval 11 monthdatefield(curdate(), INTERVAL 11 MONTH)");
Code: Select all
SELECT
*
FROM
tablename
WHERE
datefield <= curdate() - Interval 11 Month-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am