Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete records from Database if day passed

Status
Not open for further replies.

sam8599

Programmer
Feb 16, 2006
14
US
Hi,

I am trying to learn is that compare the row 'item_exp' to the current time, if the time has passed, the record needs to be remove from the database.

I will use cronjob to run it.

Code:
$SQL = "Delete from $store_item where item_exp < UNIX_TIMESTAMP (date_sub(now() interval 1 day))";

Please suggest.

TIA
 
Hi,

Yes I am using MYSQL and with column details

`item_code` varchar(25) default NULL the date is entered in format YYYYMMDD (22060526)

Table Details

Code:
CREATE TABLE `store_item` (
`item_id` int(11) NOT NULL auto_increment,
`item_title` text,
`item_desc` text,
`item_subdesc` text,
`item_code` varchar(25) default NULL,
`item_exp` varchar(75) default NULL,
`dept_id` int(11) NOT NULL default '0',
`merchant_id` varchar(75) default NULL,
`deal_coupon` varchar(75) default NULL,
`coupon_id` varchar(75) default NULL,
`sort_id` varchar(55) default NULL,
`store_image` varchar(75) default NULL,
`time_stamp` timestamp NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`item_id`)
) ENGINE=MyISAM DEFAULT AUTO_INCREMENT=10675 ;

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top