Reputation: 1481
Im tryin to develop a mysql event that subtracts the current date from a specific date entered however i am working with a criteria of 4 months, if the result of the subtraction is greater than 4 months then update a table with value '1'. So it would Be Current_date- payment_date, and if this is greater than 4 months then update flag to be '1' else '0' I want it to run daily.Please I am stuck could you help me please.
Upvotes: 1
Views: 108
Reputation: 14814
I think this is what you want:
UPDATE someTable SET someValue = (
CASE WHEN DATE_ADD( payment_date, INTERVAL 4 MONTH ) < NOW()
THEN 1
ELSE 0
END
);
When payment_date plus 4 months is less than the current date, the value is set to 1, otherwise 0.
Upvotes: 1