Deleting Records based on a certain amount of time

J

Jason

Is this possible, Say I have users that enter information and it is saved by
radio day. is there a way to query the database table (that contains the
information) and have it reference the current date and automatically delete
the day if it is over 6 months old?
 
B

Brendan Reynolds

DELETE *
FROM tblTest
WHERE (((DateDiff("m",[RadioDay],Date()))>=6));

In query design view, it looks like this ...

Field: DateDiff("m",[RadioDay],Date())
Criteria: >=6
 
O

Ofer

First, please back up.

You can use the DateAdd together with date() that return the current date,
in the criteria of a delete query

DELETE TableName.*
FROM TableName
WHERE TableName.DateField>DateAdd("m",6,Date())
 
O

Ofer

Sorry, I ment

DELETE TableName.*
FROM TableName
WHERE TableName.DateField>DateAdd("m",-6,Date())

--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benefit from it.

Good luck
 
Top