Solved

Date range criteria

Posted on 2014-10-28
2
264 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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