Search code examples
ms-access

How to write criteria for query to return dates a year before current date


I am new to Microsoft Access and have tried to look up how to write a criteria for a query on how to return dates that are a year before current date. So, since today is 9/13/2024, I would like for dates that are 9/13/2023 and before like 8/10/2023 to return as the items. The reason for this criteria is for showing any certifications that are in our database to show up in the query if they are expired. How do I write the code for this criteria?

So far, I've tried to look for variations of the code below. I know that code is for dates after the current date.

DateAdd("yyyy",-1,Date())

Solution

  • Use the expression as criteria in the GUI for the date field:

    <=DateAdd("yyyy",-1,Date())
    

    Or in SQL:

    Select * From YourTable 
    Where YourDateField <= DateAdd("yyyy", -1, Date())