Date criteria doesn't work in my query

When you use a date as criteria in an Access query, you might find that you don't get the results you expect.

Datokriterie, som ikke vil returnere de rigtige resultater

In the query shown above, the criteria >=#01-01-05#<#1/1/2010# won't work because it's not valid. The query runs, but it's likely the results will be wrong. The criteria needs the "And" operator between the dates. The criteria shown below, with the "And" operator, will work as expected:

Dette datokriterium vil fungere

To make things easier, instead of using the "greater than," "less than," or "equal to" signs, you can use "Between" with the dates and the "And" operator to do the same test, like this:

Between #01-01-05# And #01-01-10#

Notice the # characters (pound signs) that surround the dates? When you enter a date that Access recognizes, it automatically gets enclosed in # characters.

Examples of date criteria

This shows some criteria that will work, and one that won't:

Criteria

Returns records with:

>31-12-10

Dates on or after 01-01-11.

<=6/1/2014

Dates on or before 01-06-14.

25-08-13

The only the date 25-08-13.

Between 9/1 And 31-12-15

Dates on or after 9/1 of the current year and on or before 31-12-15.

>31-03-13<7/1/13

All dates. The criteria is missing the "And" operator, so it doesn't filter any results out.

Between 01-03-10 And 01-01-05

Dates on or after 01-01-05 and on or before 01-03-10. It doesn't matter that the later date is entered in the criteria before the earlier date.

Examples of date formats that Access recognizes

Here are some of the many date formats you can use in the Criteria cell:

Format

Example

m/d/yyyy

05-10-13

m/d

10/5

Access uses the current year if you don't specify one.

d-mmm-yyyy

5-Oct-2013

m-d-yyyy

3-7-1990

See Examples of using dates as criteria in Access queries for many ways to use dates as query criteria.

Del Facebook Facebook Twitter Twitter Mail Mail

Var disse oplysninger nyttige?

Fantastisk! Har du mere feedback?

Hvordan kan vi forbedre det?

Tak for din feedback!

×