how do i find a record by the most recent date

L

LondonLaps

I work for a Tech Services Company and I am trying to produce a report that
highlights when an engineer hasn't visited an outlet for a specific amount of
time. They will summit multiple records giving me "Outlet" & "Date of
Visit". I wish to be able to produce a report listing all Outlets and the
length of time it has been since the Last Visit. How do I do it?
 
J

John Spencer

Use a totals or aggregate query to get the last visited date

SELECT [Outlet], Max([Date of Visit]) as LastVisit
FROM [YourTable]
GROUP BY [Outlet]
HAVING Max([Date of Visit]) <= #2004/01/30#

That will return all Outlet that were last visited on or before Jan 30, 2004

SELECT [Outlet], Max([Date of Visit]) as LastVisit
FROM [YourTable]
GROUP BY [Outlet]
HAVING Max([Date of Visit]) <= DateAdd("yyyy",-1,Date())

That will return all Outlet that were last visited over a year ago from the
current system date.
 
Top