Solved

Date range criteria

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

860 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