Copy link to clipboard
Copied
Hi all. I have a question that should be super easy for mySQL experts....
let's say i have a table that has a field with a timestamp value (let's call it lastmodified). let's say i want to have my php script run a mysql query that does basically this (in pseudo code, i know it's not the right syntax) :
UPDATE table mytable SET status = "archived" WHERE lastmodified >= (60 days ago) AND status="complete"
in other words i want it to comb the records and find any record that has been complete and unmodified for at least 60 days, and set its status field to "completed"
Copy link to clipboard
Copied
UPDATE table mytable SET status = "archived" WHERE lastmodified <= DATE_SUB(CURRDATE(), INTERVAL 60 DAY) AND status="complete"
Copy link to clipboard
Copied
bregent, thanks for the input, ironically i had just figured it out myself, but i went about it a slightly different way. Since i found out that one could easily set the database to have "on update current_timestamp" to automatically put a timestamp every time the record was updated, it made sense to continue using timestamps not "currdate". so the solution i used ended up being :
UPDATE mytable SET status='archived'
WHERE status='complete' AND lastmodified < TIMESTAMPADD(DAY,-60,NOW())
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more