Re: Deleting mySql records based on dates

From: Date: Wed, 21 Feb 2001 13:11:14 +0000
Subject: Re: Deleting mySql records based on dates
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-40943@lists.php.net to get a copy of this message
On Wednesday 21 February 2001 14:00, Kevin Cawthorne wrote: > Try something like: > > $time = time(); // unix time now > $day_limit = 28; // how many days to allow > > $day = 86400; // how many seconds in 24 hours(1 day) > $difference = bcmul($day_limit,$day); // multiply the seconds($day) by > the day limit($day_limit) > $limit = bcsub($time,$difference); > > $sql = mysql_query("delete from table where > date<='".$limit."'", $dbh); Eeeek. Have a look at the Mysql manual sometime soon! $sql = mysql_query("delete from table where datefield <= DATE_SUB(NOW(), INTERVAL $days DAY)", $dbh); -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "These are the people who proudly call themselves "hackers" -- not as the term is now abused by journalists to mean a computer criminal, but in its true and original sense of an enthusiast, an artist, a tinkerer, a problem solver, an expert." - ESR

« previous php.general (#40943) next »