Solved

Can't get query to return today's record

Posted on 2015-02-13
4
107 Views
Last Modified: 2015-02-13
See attached.  Why won't the query return today's record?
Query-Example.accdb
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
4 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40608472
That's because your dates include time. So have the expression DateValue(RecordedDate]) and filter on that, or ensure that clean dates without a time part are entered.

/gustav
0
 
LVL 11

Accepted Solution

by:
Wilder1626 earned 250 total points
ID: 40608483
Hi

This should also work

SELECT tblRecords.ID, tblRecords.RecordDate
FROM tblRecords
WHERE (((tblRecords.RecordDate)>=Date())) and (((tblRecords.RecordDate)<=Date()+1));

Open in new window

0
 
LVL 36

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 40608513
The second part of Wilder's suggestion needs to be just < rather than <=.  You don't want midnight tomorrow to satisfy the criteria.
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40608519
That would include dates of next day at Midnight as well.
But you could use:

WHERE tblRecords.RecordDate Between Date() And Date() + #23:59:59#;

or

WHERE (((tblRecords.RecordDate)>=Date())) and (((tblRecords.RecordDate)<Date()+1));

/gustav
0

Featured Post

Independent Software Vendors: 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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

726 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