I need to create an event. In this event I delete rows of records that are older than 5 WORKING days.
Notice the WORKING days ( Monday, Tuesday, Wednesday, Thursday, Friday )
I got this so far:
CREATE EVENT `delete_news`
ON SCHEDULE EVERY 1 DAY
STARTS '2014-03-01 00:00:00'
ENDS '2014-03-31 00:00:00'
ON COMPLETION
NOT PRESERVE
ENABLE
DO
DELETE FROM news WHERE time_created < (NOW() - INTERVAL 5 DAY)
How can I determine the WORKING days in mysql?
Edit:
DELETE FROM news
WHERE
time_created < ( NOW( ) - INTERVAL (
CASE WEEKDAY(time_created)
WHEN 4 THEN 7
WHEN 5 THEN 6
ELSE 5
END)
DAY )