Deleting Records based on a certain amount of time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
DELETE *
FROM tblTest
WHERE (((DateDiff("m",[RadioDay],Date()))>=6));

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

Field: DateDiff("m",[RadioDay],Date())
Criteria: >=6
 
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())
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top