Office & Productivity Software forum

General discussion

MS Access - Between Dates queries using variables from forms

by sheilasabado / June 13, 2010 8:05 PM PDT

I have a table with [Call Start] as Date/Time General Date which has data from March 30, 2010 until May 9, 2010. I want to create a query wherein I can get a date range from user given starting and ending date from a Form (GenForm):

User enters ff value in GenForm:

StartDate = 07-Apr-10
EndDate = 09-May-10

This is my query in MS Access Design View

Field: Format([Call Start],"Short Date")
Criteria: Between Format([Forms]![GenForm]![StartDate], "Short Date") And Format([Forms]![GenForm]![EndDate], "Short Date")
Result: It gives me data only for Apr 7, April 8, April 9, May 7, May 8 and May 9.

I think it only looks at the days of the date and not the entire date. Anyone can help me, please?

Post a reply
Discussion is locked
You are posting a reply to: MS Access - Between Dates queries using variables from forms
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: MS Access - Between Dates queries using variables from forms
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -

You're nearly there. Don't format, just compare the dates.

Field: any date/time field
Criterion for the field: >= [Forms]![GenForm]![StartDate] and <= [Forms]![GenForm]![EndDate]

Your thought about what it does are right. The format results in a string, so the comparison is a string comparison, not a date comparison. And "10" isn't between "07" and "09", is it. So any string starting with "10" isn't between "07-" and "09-".


Collapse -
by gisquared / March 23, 2012 6:05 AM PDT
In reply to: Solution.

This exactly what I needed... thank you... I changed it a bit though. for us...we have a page where we always want two weeks out from a single date so I used:

>=[Forms]![Main Menu]![Monday Date] And <=[Forms]![Main Menu]![Monday Date]+14

Works like a charm.

Popular Forums
Computer Help 51,224 discussions
Computer Newbies 10,453 discussions
Laptops 20,090 discussions
Security 30,722 discussions
TVs & Home Theaters 20,937 discussions
Windows 10 1,295 discussions
Phones 16,252 discussions
Windows 7 7,684 discussions
Networking & Wireless 15,215 discussions

Finding the best 360 camera

GoPro, Pixpro, or Ricoh?

You can spend hundreds or even thousands of dollars on a 360-degree camera. We tested three of them to find out what kind of quality and ease of use you can expect at each price point.