Delete MySQL Rows Older Than Date
I ran into a problem recently where I needed to delete all rows in a MySQL table that were older than three months. This I was able to accomplish with the following statement:
Substitute table and column, and a proper date option. The date_sub function subtracts a time period from the date specified. In this statement, NOW() grabs the current date from which INTERVAL 3 MONTHS is subtracted (along with the < operand).
About Benjamin Perove
Benjamin has been associated with computer technology starting from a very early age, and has contributed to the success of many businesses and enterprises since 2001.
He loves to crush pow at Keystone, play acoustic guitar, climb rocks, and ascend mountains on his road bike.
Benjamin is an Avalanche fan and currently resides in Boulder, Colorado.

Comments(8)

