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 derfloh 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
Joined
Feb 16, 2006
Messages
14
Location
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
 
Would it be correct to assume that you are using MySQL?

What is the columntype of the column named item_exp?



Want the best answers? Ask the best questions! TANSTAAFL!
 
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
 
No, I'm interested in item_exp, which is the columnname you are referencing in the WHERE clause of your query.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top