cjbeck71081 Posted September 16, 2008 Share Posted September 16, 2008 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 https://forums.phpfreaks.com/topic/124484-datediff-to-select-entries-older-than-30-days/ Share on other sites More sharing options...
fenway Posted September 16, 2008 Share Posted September 16, 2008 Why not just WHERE signup_date < CURDATE() - INTERVAL 30 DAY ? Link to comment https://forums.phpfreaks.com/topic/124484-datediff-to-select-entries-older-than-30-days/#findComment-642854 Share on other sites More sharing options...
cjbeck71081 Posted September 16, 2008 Author Share Posted September 16, 2008 I am all for that, what is the proper syntaxt for that? Link to comment https://forums.phpfreaks.com/topic/124484-datediff-to-select-entries-older-than-30-days/#findComment-642859 Share on other sites More sharing options...
Barand Posted September 16, 2008 Share Posted September 16, 2008 I am all for that, what is the proper syntaxt for that? the correct syntax can be found here http://www.phpfreaks.com/forums/index.php/topic,216892.msg991854.html#msg991854 Link to comment https://forums.phpfreaks.com/topic/124484-datediff-to-select-entries-older-than-30-days/#findComment-642890 Share on other sites More sharing options...
fenway Posted September 16, 2008 Share Posted September 16, 2008 LOL. Link to comment https://forums.phpfreaks.com/topic/124484-datediff-to-select-entries-older-than-30-days/#findComment-642913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.