[wd_asp elements=’search’ ratio=’100%’ id=1]

Datediff – Find records where data > 24 hours old

30th May 2014

MySql

mysql codehaven category

‘added’ is the column name that has timedate

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)

DELETE FROM cmdata WHERE date < DATE_SUB(NOW(), INTERVAL 7 DAY)

and if depending on a column value

mysql_query("DELETE FROM myreports WHERE added < (now() - interval 31 DAY) AND platform='facebook'");