MySQL deletes data from table
I have a timestamp value in a column of my table. I need to keep all the data from the past week and delete the remainder data in the table (which is not the last 7 days) How can i do this?
The request I tried is below.
DELETE * FROM EmailMainTable WHERE DATE_FORMAT(timestamp, '%Y-%m-%d %H:%i:%s') >
DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:%s'), INTERVAL 8 DAY);
NOTE. My filed name is a timestamp and I converted it to bigint
My table structure:
+3
user4125170
source
to share
2 answers