Click to See Complete Forum and Search --> : working with dates


notaguru
08-31-2005, 08:16 PM
Am doing for myself some code to remind me via email of birthdays (dont want spam so am coding it myself) this how far i got:

I did a control panel putting the data (name, birthday, etc), and it tells me THE SAME DAY that the date is due like this:

$datenow=date("Y-m-d");
$sql = mysql_query ("select * from data WHERE date = '$datenow'");
...

I want to be able to send me an email 7 days before, how could this be done?

I have a cron job running the script every day.

Thanks.

NogDog
08-31-2005, 09:29 PM
$query = "SELECT * FROM `data` WHERE DATE_SUB(`date`, INTERVAL 7 DAY) = '$datenow'";
$sql = mysql_query($query);