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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.