Solved

Date range criteria

Posted on 2014-10-28
2
261 Views
Last Modified: 2014-10-28
I want to query data based on a form.  The form has a single date field named txtEndDate.

But in the query criteria I have:

Between [Forms]![frmDate]![txtEndDate]-365 And [Forms]![frmDate]![txtEndDate]

which I'm sure isn't the right way to do it especially if it was a leap year.  I want to end up querying from a year ago through the date entered on the form.

How should my criteria read?

--Steve
0
Comment
Question by:SteveL13
  • 2
2 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40408410
I would suggest

Between DateAdd("yyyy",-1,[Forms]![frmDate]![txtEndDate]) And [Forms]![frmDate]![txtEndDate]
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40408416
Just bear in mind - today is Oct 28. If someone types in Oct 28, 2014, and you have something with a date and time of Oct 28, 2014 12:00, then it won't be caught by "Oct 28, 2014", because Access will assume that it is midnight of that day.

Therefore, you may want

>=DateAdd("yyyy",-1,[Forms]![frmDate]![txtEndDate]) And <[Forms]![frmDate]![txtEndDate]+1

or

>=DateAdd("yyyy",-1,[Start]) And <DateAdd("d",1,[Start])

if that is a possibility.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now