Delete records older than one year

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

Guest

How can write a delete query to delete records in a table where the Date
field formatted 1/15/04 is older than 1 yr. from today? Thanks
 
Save your data first, there will be no return

try this

DELETE TableName.*
FROM TableName
WHERE TableName.DateFieldName<DateAdd("yyyy",-1,Date())
 
"Why?" Why do you want to delete records older than 1 year?

Is your database experiencing performance issues? Are you trying to create
separate databases for each year?

You've asked "how" to do something. Can you describe the underlying
business need?

Regards

Jeff Boyce
<Office/Access MVP>
 
How about dates 15 days old?

A criterion of

< DateAdd("d", -15, Date())

will return all records where the datefield upon which you use the
criterion is older than 15 days ago.
And how about today's records?

=Date()

Open the VBA editor by typing Ctrl-G (to get to the proper Help file)
and take a look at the online help for DateAdd and DateDiff.


John W. Vinson[MVP]
 
Back
Top