Hi Dermot,
You don't mention what database you are using, but I'll assume TPS.
(for SQL a simple prop:sql, or a stored procedure will work fine.)
So, first thing to do is determine the date range you want to delete.
to do that we want to know the current time, and subtract some fixed amount from that.
Lets say you want to keep records for 30 days after they are deleted.
currentTime real
net _NetAll ! any NetTalk class will work.
keepfor Equate(30 * 24 * 60 * 60 * 1000)
currentTime = net.GetElapsedTimeUTC()
! so delete all records which have a dts >0 and dts < currentTime-KeepFor.
Smart play is to have a key on the dts field. but with, or without that, simply scan through the table looking for records with dts >0 and dts < currentTime-KeepFor and delete them. (While it depends on the table, there's probably not a lot of them.)
You can call PACK at the end if you like, but as far as I know it doesn't do anything to a TPS file.
cheers
Bruce