Find the Latest Transaction Date per Equipment ID in Microsoft Access
Question details
Find the latest transaction date before a specified cutoff for each Equipment ID.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A transaction table contains equipment IDs and dates, and the user needs one latest qualifying date for each ID.
- Observed behavior
- A query using TOP 1 returns the latest result overall rather than a latest date for every Equipment ID.
Check the table and field names in Access, and identify the cutoff date. The example uses Database Table, Equipment ID, and Transaction Date; replace them with your actual names if necessary.
Filter Transaction Dates Before Grouping by Equipment ID
Use a WHERE clause and MAX to return the latest qualifying date for each equipment ID.
The WHERE clause excludes dates on or after the cutoff before MAX is calculated for each Equipment ID.
In Access, open the database, select Create > Query Design, and switch to SQL View.
Enter: SELECT [Equipment ID], MAX([Transaction Date]) AS LatestDate FROM [Database Table] WHERE [Transaction Date] < #2016-06-30# GROUP BY [Equipment ID];
In SQL View, replace the table name, field names, and #2016-06-30# cutoff with the values for your database. Keep the date between # symbols.
Select Run on the query design ribbon to view one latest qualifying date for each Equipment ID.

Work With Transaction Data in WPS Spreadsheets
WPS Office is a free, lightweight, easy-to-use alternative for working with exported transaction data. Its familiar interface and Microsoft Office format compatibility make it easy to move spreadsheet files between applications. It does not run Microsoft Access database queries.

Frequently Asked Questions
Why shouldn't I use TOP 1 in this query?
TOP 1 limits the overall query result rather than returning one date for each Equipment ID. Use GROUP BY [Equipment ID] with MAX([Transaction Date]) instead.
How do I include transactions on the cutoff date?
If Transaction Date contains time values, use a WHERE condition that is less than the next day, such as [Transaction Date] < #2016-07-01#, to include all times on June 30.
Why is an Equipment ID missing from the results?
An ID is omitted if it has no transaction date satisfying the WHERE condition. Check its dates against the cutoff in the source table.
Does this query return the entire transaction record?
No. The SELECT statement returns the Equipment ID and its latest qualifying date. Returning other transaction fields requires an additional query or join, and tied dates can produce multiple records.




