Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dates not working 2

Status
Not open for further replies.

LimitedTech

Technical User
Aug 4, 2008
71
US
I have dates formatted as general date. Input mask in forms is 99/99/0000\ 00:00;0;_ When I try to query these dates using #02/18/2018# nothing results. If I use a between with the previous day and next day it will work. What am I doing incorrectly?
 
Hi

If the dates in your table also have a time component, for instance 2/18/2018 08:43, then the value will be Equal to or Greater than 2/18/2018 And Less than the next day., 2/19/2018.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thanks. Evidently I have never used a date with a time component in the same field.
 
Well, here, in North Texas it's 2/19/18 18:04:37.

That's just a display value. The ACTUAL value is 43150.7532. That is
1) 43,150 days since December 31 1899 (meaning that 1 would be displayed as 1/1/1900) and
2) the time value is 7,532 ten-thousandths of a day, which is displayed as 18 hours and 4 minutes and 37 seconds.

If you want to use #02/18/2018# in your SQL, then you'll need to do something like this...
Code:
Where Int([Your Date Field]) = #02/18/2018#
... in order to return the integer portion of the date/time value.




Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I can't try it right now but just curious can I also use Where Int([Your Date Field]) = date() to return the records that have the current date?
 
LimitedTech,

You can easily test this kind of stuff (when you can run Access). I open the debug/immediate window (press Ctrl+G) and enter something like:

Code:
? Int(#2/20/2018 6:00PM#)=Date()
True
? Int(Now())=Date()
True

I prefer to use the DateValue() function to strip the time from a date/time value.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top