#  Other Applications & Softwares  > Access Tables & Databases >  >  Syntax error in date in query expression "#".

## baijixu

Hey guys!

I have an issue I cant seem to resolve.

I am running a query where an excel report will pull agent data from an access database into an excel table.  I need it to filter out agents that have a term date older than 90 days.  My term date column in access is [TERM_DATE] and it is set to Short Date format.  So in the query, I have it check a bunch of other parameters that works fine such as MU_ID, AGENT_NAME etc.

Here is my SQL query:



```
Please Login or Register  to view this content.
```


The results of this query: it only pulls agents to have a term date set in the database that is not older than 90 days and excludes all the other agents that have a null/blank [TERM_DATE].  When I add the 'OR Is Null' to the query:



```
Please Login or Register  to view this content.
```


It ignores ALL the other parameters and pulls all 500 agents who have a null [TERM_DATE]

So, in summary, I cannot get the SQL query to Access to filter out agents who have a [TERM_DATE] older than 90 days while still filtering the other parameters and still pulling agents who have a null/blank [TERM_DATE]


While trying to fix this I noticed that my [TERM_DATE] column was text.  So I changed it to short date instead and now my second problem is, my update macro gives me an expression error on the date.  Here is my code:




```
Please Login or Register  to view this content.
```


So really, 2 issues.  I cant filter results and I cant update my database.  :Confused:

----------


## Norie

What do you have in fields MU1-MU5?

----------


## baijixu

MU_ID is the business unit ID number for our team configuration, which is different than the Access ID that is auto assigned per entry.  So the MU1-5 is checking excel cells for each MU_ID to lookup.   In the spreadsheet, one would choose an MU or business and MU1 - MU5 would populate with an MU_ID associated with that MU to feed the query parameters.

A row in my database looks like this:



```
Please Login or Register  to view this content.
```


So essentially, I want the query to pull by MU_ID, SUPERVISOR and if TERM_DATE is null or less than 90 days old.

----------


## alansidman

If you want dates older than 90 days in the past, you will need to change the greater than sign to a less than sign in your SQL statement, as you are looking for dates that have values less than 90 days ago.  Access stores dates as numerical values beginning with Jan 1, 1900.  Today, June 12 would be 41802 and 90 days ago would be 41712.  I hope this helps.

----------

