Others

How to Retrieve the Last Three Years of Data in an Access Query

Steven ParkerSteven Parker Oct 21, 2026 869 views

Question details

The user needs to configure an Access query to successfully display records from the last three years based on a specific date field.

How to Retrieve the Last Three Years of Data in an Access Query
Product
Microsoft Access
Device & OS
not provided
Scenario
Modifying query criteria to dynamically filter data for the current year and the previous three calendar years.
Observed behavior
Attempting to filter dates using the Between operator combined with Boolean expressions returns no records.
Before you start

Verify that the field you are attempting to filter (e.g., Book Date) is strictly formatted as a Date/Time data type in your table's Design View, as date math functions will fail on text fields.

Solution 1Recommended

Filter by Year Using the Date Function in Design View

Replace the 'Between' operator with a dynamic mathematical comparison using the Year() and Date() functions to reliably filter recent records.

Using the Year() function extracts the four-digit year from both your data field and the current system date. By subtracting from the current year, Access can easily determine which records fall into your desired timeframe without complex Boolean logic.

1
Open Query Design

Open your Microsoft Access database, right-click on the query you want to modify in the Navigation Pane, and select 'Design View'.

2
Locate the Date Field

Find the column containing your target date field (such as [Book Date]) in the query design grid.

3
Enter the Criteria

In the 'Criteria' row directly underneath your date field, type the following expression: > Year(Date()) - 3

4
Run the Query

Click the 'Run' button (the red exclamation mark) in the Query Design ribbon to view your filtered results.

Filter by Year Using the Date Function in Design View
Calendar Years vs. Exact Days: This method returns records from the current calendar year plus the previous three. If you need exactly the previous 1,095 days (3 full years from today's exact date), use >= Date() - 1095 in the Criteria row instead.
Free Microsoft Office alternative

Need a lighter way to analyze data? Try WPS Office

While Microsoft Access is powerful for complex relational databases, many data tracking and filtering tasks can be handled far more easily in a spreadsheet. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office, featuring a robust Spreadsheet tool for straightforward data analysis.

  1. 1. Install WPS Office: Download and install WPS Office for free from the official website.
  2. 2. Import Your Data: Export your Access table as an Excel file, then open it directly in WPS Spreadsheet.
  3. 3. Filter Dates Easily: Use the built-in 'Data Filter' tool in the ribbon to instantly filter records by year, month, or custom date ranges without writing SQL queries.
100% compatible with Microsoft Excel formats (.xlsx, .xls, .csv)Lightweight installation that runs smoothly on most devicesFree built-in data filtering, sorting, and PivotTable toolsFamiliar user interface for a seamless transition from Microsoft Office
microsoft office alternative - wps office

Frequently Asked Questions

Why does using the Between operator fail in my Access query?

The Between operator requires two distinct, properly formatted date endpoints (e.g., Between #1/1/2020# And #12/31/2023#). If it is combined with complex Boolean logic or dynamically generated date functions without strict formatting, Access may misinterpret the criteria, resulting in syntax errors or zero returned records.

How can I filter an Access query to show data from exactly one year ago?

To filter records starting exactly 365 days prior to the current system date, enter >= Date() - 365 in the Criteria row of your date field. This calculates the exact day rather than relying on the calendar year boundaries.

Can I prompt the user to enter the number of years dynamically?

Yes, you can use a parameter prompt. Enter an expression like > Year(Date()) - [Enter number of years:] in the Criteria row. Whenever the query is run, Access will pop up a dialog box asking the user to input the desired number.