Solved

Date range criteria

Posted on 2014-10-28
2
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

733 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