timmylogue Posted April 10, 2015 Share Posted April 10, 2015 I'm trying to search for passed dates (30 days ago) in my database and then INSERT 'expired' value into a column called 'trial_date_ended'. The dates/passed dates are in a column field called "trial_date_started" Here an example of what I thought would work but doesn't work: $sql="INSERT INTO users (trial_date_ended) VALUES ('expired') < (NOW() - INTERVAL 30 DAY)"; Thanks for your help! Tim Quote Link to comment https://forums.phpfreaks.com/topic/295394-find-30-days-ago-and-insert/ Share on other sites More sharing options...
Solution Barand Posted April 10, 2015 Solution Share Posted April 10, 2015 Sounds like you need an UPDATE query UPDATE users SET trial_date_ended = 'expired' WHERE trial_date_started < CURDATE() - INTERVAL 30 DAY Quote Link to comment https://forums.phpfreaks.com/topic/295394-find-30-days-ago-and-insert/#findComment-1508661 Share on other sites More sharing options...
timmylogue Posted April 10, 2015 Author Share Posted April 10, 2015 Thank you! Worked! Quote Link to comment https://forums.phpfreaks.com/topic/295394-find-30-days-ago-and-insert/#findComment-1508682 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.