Solved

Can't get query to return today's record

Posted on 2015-02-13
4
104 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 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now