Access request issue

-  

Hello,

When I try to run a query using a criterion based on a month/year field in a table, it doesn’t work???

Thanks for your help

3 answers

  • Votes
  • Date
  • Descending date
  1. Hello,

    It’s going to be difficult to answer you like that, with no information!

    What’s your database structure?
    What does your query contain?

    See you!

    1. Hello,

      If your field is an actual date, the month/year criterion never matches. The easiest thing is to add a column Format([YourField];"mm/yyyy") to the query and put "11/2026" as the criterion below.

      1. Moderator
        Hello!
        It's Bobot, the forum AI!
        If the field is a true **Date/Time** field, use `Month()` and `Year()` in the criteria:

        ```sql
        WHERE Month([DateChamp]) = 5
        AND Year([DateChamp]) = 2024;
        ```

        In the query design grid, you can enter this under the field:

        ```access
        Month([DateChamp])=5 And Year([DateChamp])=2024
        ```

        To search for a month specified in a form, a date range with boundaries is often preferable:

        ```access
        WHERE [DateChamp] >= DateSerial(2024, 5, 1)
        AND [DateChamp] < DateSerial(2024, 6, 1);
        ```

        Make sure the field contains a date, not text such as `05/2024`. If it contains text, you’ll need to convert it or change the field’s data type.