Solved

Can't get query to return today's record

Posted on 2015-02-13
4
105 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
  • 2
4 Comments
 
LVL 49

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 35

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 49

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

815 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

11 Experts available now in Live!

Get 1:1 Help Now