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 -
Solution.

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-".

Kees

Collapse -
Thanks
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
icon
Computer Help 47,885 discussions
icon
Computer Newbies 10,322 discussions
icon
iPhones, iPods, & iPads 3,188 discussions
icon
Security 30,333 discussions
icon
TVs & Home Theaters 20,177 discussions
icon
HDTV Picture Setting 1,932 discussions
icon
Phones 15,713 discussions
icon
Windows 7 6,210 discussions
icon
Networking & Wireless 14,510 discussions

Big stars on small screens

Smosh tells CNET what it took to make it big online

Internet sensations Ian Hecox and Anthony Padilla discuss how YouTube has changed and why among all their goals, "real TV" isn't an ambition.