Date Range Syntax Access 2003

I would like some syntax eamples for Access 2003 for date range queries.


Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

PatHartmanConnect With a Mentor Commented:
Since when is a literal a good example?  Do you hard code dates in your queries?

1.  Refer to controls on a form - make sure they are defined as date format:
Where SomeDate Between Forms!yourform!StartDate and Forms!yourform!EndDate

2. Other cfields in the query
Where SomeDate Between StartDate and EndDate

3. Using TempVars (probably not available in A2003)
Where SomeDate Between tvStartDate.Value and tvEndDate.Value
Pawan KumarConnect With a Mentor Database ExpertCommented:
Try this..

SELECT * from TableName WHERE CDATE(ColumnName) between #2016-01-01# and #2016-01-31#
Gustav BrockConnect With a Mentor CIOCommented:
Your date field should be of data type Date, thus CDate is not needed. It is simply:

Select * From YourTable Where YourDateField Between #2016/07/01# And #2016/08/31#

Open in new window

Or what do you have in mind?

The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

submarinerssbn731Author Commented:
Thanks to you both!!!
Pawan KumarDatabase ExpertCommented:
Sir, if you dont need more info on this question, Could you please accept one or more answer as solution and close the question.

Thank you!
Dale FyeConnect With a Mentor Commented:
Another issue you need to understand is that if your Date field contains time values as well as the date, then in order to get all of the records for today, it would be best to use a criteria like:

WHERE [YourDateField] >= #2016/09/04# AND [yourDateField] < #2016/09/05#

By default, Access uses the date format "mm/dd/yy" when referring to dates, but the syntax displayed above "yyyy/mm/dd" is more acceptable for international applications.
submarinerssbn731Author Commented:
Thanks to you all!
Pawan KumarConnect With a Mentor Database ExpertCommented:
CDATE function to used since we don't know what is the data type of the column. The Author has not mentioned it.

So effectively if the data type if Date then we can remove but if the data type is other than date then we may need to convert it before comparison. We came across many examples where the date is stored as char/Varchar, so thats why CDate is mentioned.

For example -

Also even if is used it will do the job.

Anyways ! Thanks !
Gustav BrockCIOCommented:
Using CDate([ColumnName]) is not a typical method used when filtering for a date range.
All Courses

From novice to tech pro — start learning today.