View Full Version : How to delete record after x days
08-07-2002, 02:34 PM
Any one suggest how I get my code to automatically delete all records in the d/b that are older than x days, and how should I implement this code in my site? ie where would this code be inserted?
Or should I just filter the records by date and let them all build up in the database?
08-07-2002, 05:11 PM
How are you keeping track of how old a record is? By a seperate field? if so you can use 'Now()' which is today's date and if a date is older than X days old call your delete routine.
DateDiff("d", nameofrecord, Now())
which gives you back a number and if that number is greater than or equal to the number X days delete that entire record
if you need me to give code I will, but I don't think I need to :thumbsup:
08-08-2002, 12:17 AM
Ok thats helpfull, thanks, where exactly would one insrt this code in regards to the entire site? I dont want to compamise speed on the front page, is there a way of automatically calling a routine based on time of DAy? say have a seperate page run automacally every day.
Yes it is.
See the thread : schedduling executions.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.