MajP
You've got your good things, and you've got mine.
- Local time
- Yesterday, 22:09
- Joined
- May 21, 2018
- Messages
- 9,824
@Minty. I disagree with the above. I date field can definitely have a zero time component (fraction of a day since midnight). I did not say null. A zero time component is 12:00:00 AM. This is the default when you use a date picker or type in a date without the time. Also the Between operator is inclusive meaning it is a >= and <=. So if this is my data
tblTest tblTest
And I want values between 1/1 and 1/3, I cannot add an extra day to the end.
That returns the below values including 1/4/2021
Query1 Query1
So I either need to first convert dtmDate only to date values or I need to change my between to include the end time
tblTest tblTest
ID | dtmDate |
---|---|
1 | 1/1/2021 6:00:00 PM |
2 | 1/2/2021 |
3 | 1/3/2021 |
4 | 1/3/2021 3:13:00 PM |
5 | 1/4/2021 |
Code:
SELECT tblTest.dtmDate
FROM tblTest
WHERE (((tblTest.dtmDate) Between #1/1/2021# And #1/4/2021#));
That returns the below values including 1/4/2021
Query1 Query1
dtmDate |
---|
1/1/2021 6:00:00 PM |
1/2/2021 |
1/3/2021 |
1/3/2021 3:13:00 PM |
1/4/2021 |
Code:
SELECT tblTest.dtmDate
FROM tblTest
WHERE (((tblTest.dtmDate) Between #1/1/2021# And #1/3/2021 23:59:59#));