Deleting records after certain date

S

sendahook

Wayne said:
I would expect criteria of

=DateAdd("d",-7,Date())

to do what you need. Due to the way dates are stored, it is also
possible to
just subtract the number of days.

=Date()-7

I just tried this on some test data and it worked.

DELETE * FROM TableName WHERE FieldName = Date()-7;

--
Wayne Morgan
MS Access MVP


"sendahook" [email protected] wrote in
message

Hello,
I would like to automatically delete records after a 7 day period. I
read a previous post on how to automatcially delete records based on
a
delete query using a DateAdd function in the criteria ie...
DateAdd("d",-7,Date())
This works only if the current date is exactly 7 days past. In other
words, if it's the 21st, it will only delete the records that have
the
14th in the said field. That would be fine if the query was run
everyday, but with my application it may not be accessed for 2-3 days
at a time.

Basically, I'm looking for the right expression to use to delete the
records 7 days old AND OLDER. I've tried some expressions using ""
or
"" but I'm having no luck so far....any suggestions would be greatly
appreciated!

Thanks


Thanks Wayne....but I'm still getting the same result as I did before
with it only hitting on the records that are exactly 7 days prior
instead of 7 days old AND older. Do you know is there a way to
incorporate an "equal to or greater than" expression in there somewhere
to acheive this?
 
W

Wayne Morgan

I had <= in what I posted. What you quoted back just had =. "<=" is "less
than or equal too".
 
Top