‘added’ is the column name that has timedate
1 2 3 |
SELECT count(*),campaign FROM reports WHERE HOUR(TIMEDIFF(NOW(), added)) >=24 |
You can also use this (Deletes all records that are older than 31 days)
1 2 3 |
DELETE FROM cmdata WHERE date < DATE_SUB(NOW(), INTERVAL 7 DAY) |
and if depending on a column value
1 2 3 |
mysql_query("DELETE FROM myreports WHERE added < (now() - interval 31 DAY) AND platform='facebook'"); |