Filter Query based on Date and Time (1 Viewer)

kobiashi

Registered User.
Local time
Today, 00:53
Joined
May 11, 2018
Messages
258
hi

im trying to create a criteria to filter a query based 02:00 yesterday and 02:00 today


i have tried

Code:
[DateField]+[TimeField] as expr1

between Date()-1 & #02:00:00# and Date() & #02:00:00#


but its not filtering, please can someone point in the right direction please
 

June7

AWF VIP
Local time
Yesterday, 15:53
Joined
Mar 9, 2014
Messages
5,466
between Date()-1 + #02:00:00 AM# and Date() + #02:00:00 AM#
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:53
Joined
Feb 19, 2002
Messages
43,233
To clarify, Dates are NOT strings. They are double precision numbers. When you concatenate a string with a date using the ampersand, you convert the date to a string and so it behaves like a string rather than like a date. Strings are evaluated left to right, character by character so

01/01/2019 2:00 PM turns out to be LESS THAN
02/01/2018 2:00 PM

That is why June suggested "adding" the time to the date. That will not convert the date to a string. It will leave it as double precision and so it will be evaluated as a date rather than a string.
 

Users who are viewing this thread

Top Bottom