Jump to content

Datediff to select entries older than 30 days


cjbeck71081

Recommended Posts

I have a membership sign up where a user signs up for an account online and a timestamp for thier sign up is puting the SQL table along with thier info.

 

I would like to email the person when thier membership is older than 30 days and tell them that they have to check into thier account and update thier information.

 

I know i can do this by brigning down the entries and calculating difference between dates... but i would like to run a query that does it for me.

 

I have been looking into DATEDIFF and i think what i need is the syntax to properly pull down the email addresses of everyone whose membership is older than 30 days

 

 

It might look like

 

$result = "SELECT * FROM mytable WHERE DATEDIFF(`signup_date`, '$todays_date') > 30";

 

From there i could

 

foreach($row = mysql_fetch_array($result)){

mail($row['email'],"Update your account", "Please update your account", $headers);

}

 

Any ideas... i'm sure my syntaxt is not even close on the SQL, but the idea is there.

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.