I have a table with
*PwdSettings that has a value of -50 (which is say 50 days)
*PwdDate (which is the date last updated)
*ExpDate (which is 0 or 1, if Password is old i need it set to 1)
I’m trying to write a query to say “IF PwdDate is < PwdSettings Then SET ExpDate = 1”
Here is what I have tried so far, everything throws an error.
UPDATE wp_users SET ExpDate = 1 WHEN PwdDate < DATE_ADD(CURDATE(), INTERVAL -50 DAY) WHERE user_email='dylan@wccit.com'
UPDATE wp_users SET ExpDate = 1 WHERE user_email='dylan@wccit.com' IF(PwdDate < DATE_ADD(CURDATE(), INTERVAL -50 DAY))
IF PwdDate < DATE_ADD(CURDATE(), INTERVAL -50 DAY) WHERE user_email='dylan@wccit.com' THEN SET ExpDate = 1
Use:
…or, using DATE_SUB: