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!

Comparing dates in Access

Status
Not open for further replies.

Rich24

MIS
Oct 5, 2002
52
US
Hi, I’m new to the forum, and getting better with Access, but I’m still pretty new t it. I’m trying to write a query that will compare dates of food inspections. I need to check over a 3-year period if any inspection has lapsed more than 7 months from the previous. For each record I need to compare date 1 to date 2, if not more than 7 months then compare date 2 to date 3, and so on. If any 2 dates are more than 7 months, the record must be selected.
I used a little SQL in school a few years back, but I’m sure I could figure out how to do it if you can give me an example of the syntax.
 
Code:
select stuff
  from yourtable
 where datediff('m',date1,date2) > 7
    or datediff('m',date2,date3) > 7

rudy
 
Thanks Rudy, it worked like a champ. Can you recommend a beginner’s book on SQL? Just need something with the basics and a lot of examples. Thanks again.

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top