I want to run a nightly cron job where you iterate throught each row of a single table and reset a field depending on the conditions specified. In this case I want to take a date field (RenewalDate) and compare it to the current date less a 30 day grace period and if true reset the (SubscriptionEpired) field to a 1 (true).

RenewalDate >=(${now} - 30) SubscriptionExpired = 1

Both fields are in a single table called Restaurants

RenewalDate date (yyyy-mm-dd)
SubscriptionExpired int(1)

Will something like this work or do I need something different?

UPDATE Restaurant SET SubscriptionExpired = 1 WHERE TO_DAYS(NOW) - TO_DAYS(RenewalDate) < 30;

Thanks,

Jack


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to