Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help getting records less than 7 years old

Status
Not open for further replies.

meckeard

Programmer
Aug 17, 2001
619
US
All,

I am trying to get records using a query/recordset in a module for Access 97 and need to get everything that is less than 7 years old from the date it's run.

Since I was not able to get it to by getting the actual number of days in the past 7 years, I guessed at the days. But as most can figure out, it's not very accurate and some records get through.

This is what I had in my where clause:

DateDiff(""d"", [Date into OD], Date()) < 2555

What can I replace the 2555 with that will give me the exact number of days going back 7 years to the day?

Thanks,
Mark
 
A starting point:
WHERE [Date into OD] > DateSerial(Year(Now)-7,Month(Now),Day(Now))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,

Why not calculate a date, 7 years earlier thatn today?
Code:
Where TheDate < DateSerial(year(Date())-7, Month(date()), day(date()))


Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top