Jump to content

[SOLVED] How can i delete records older than 2 months?


Poddy

Recommended Posts

Hi, i want to run a cronjob at my application to delete records which are older than 2 months

i tried using

$sql = "SELECT * FROM `feeds` WHERE `timestamp`='DATE_SUB(CURDATE(), 60)'";
$result = mysql_query($sql) or die ('error' . mysql_error());
$row = mysql_fetch_assoc($result);
print_r($row);

note: this is a select because so far i cannot even select them..

 

this row returns me an empty result set

the timestamp is feeded by the CURRENT_TIMESTAMP and is a timestamp type

in the following format: 2008-05-29 14:53:38

 

thanks in advance to all helpers

 

TRy:

 

$sql = "SELECT * FROM `feeds` WHERE `timestamp`='DATE_SUB(CURDATE(), INTERVAL 60 DAY)'";

$result = mysql_query($sql) or die ('error' . mysql_error());

$row = mysql_fetch_assoc($result);

print_r($row);

 

You missed out INTERVAL and DAY

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.