Removing rows from MySQL table where the timestamp is over one day old?
Posted
by Rob
on Stack Overflow
See other posts from Stack Overflow
or by Rob
Published on 2010-05-08T21:36:38Z
Indexed on
2010/05/08
21:38 UTC
Read the original article
Hit count: 123
I found the exact same question here.
But it isn't working for me. I've modified it a bit, manipulated it, and I can't figure it out. I'm trying to remove rows that are over a day old. Here is my code:
if (isset($_POST['prune'])) {
$sql = "DELETE FROM logs WHERE time < date('now', '-1 days')";
mysql_query($sql);
echo 'Logs older than one day removed.';
}
Fairly simple question I suppose, but its bugging the hell out of me. I would appreciate any help.
In case it makes a difference, the column is a TIMESTAMP
type.
© Stack Overflow or respective owner