Giffyguy
Giffyguy

Reputation: 21302

How Can I Perform Date Comparisons in Access 2013 Query Criteria?

I have a date field in my table, and I'm writing a query in Access 2013 to select all items where the date is between 7-days-ago and 30-days-in-the-future.

Currently, I've added the following as "criteria" under the date field:

>=Today()-7 And <=Today()+30

But I get the following error when I try to save the query:

I've tried using DateDiff (as I have in other scenarios) but it tells me that I'm not allowed to use that type of expression as criteria.

EDIT: This is an Access 2013 custom web app for SharePoint 2013, and all the available functions and syntaxes appear to be different from those available in a desktop database file.

Upvotes: 1

Views: 2892

Answers (1)

Andy G
Andy G

Reputation: 19367

You might be confusing with the Excel function named TODAY(). In Access it is called Date().

You can also use Between..And.

Between Date()-7 And Date()+30

Added In response to advice about using SharePoint: I don't use SharePoint, but might guess that you need to specify the field explicitly:

fieldName >= Today()-7 And fieldName <= Today()+30

you might use brackets to make the statement clearer:

(fieldName >= Today()-7) And (fieldName <= Today()+30)

Upvotes: 1

Related Questions