DateTime Query

liammoohan

Board Regular
Joined
Jan 11, 2008
Messages
72
I have a query that obtains a value from a datetime field and using the Now() function I specify the below:

IIf(Now()>=[WashTime],"ELIGIBLE")

This then returns the results as blank (see below):

1666008798695.png


I then change to:

IIf(Now()<=[WashTime],"ELIGIBLE")

I then get the below and cannot figure out why when the "Wash Time" is less than the time "Now()" why it won't return "ELIGBLE" when it meets the criteria!?!

1666008902019.png


Any assistance in figuring this out would be much appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
What is the Data Type of WashTime?
It looks to me that it might be left-justified, which would suggest a String Data Type instead of a Date/Time one.
 
Upvote 0
What is the Data Type of WashTime?
It looks to me that it might be left-justified, which would suggest a String Data Type instead of a Date/Time one.
Hi Joe4

The WashTime originates from a field name [Spin] and is a datetime field; using a another query I am adding 3.5 hours to the date/time using the below code:

WashTime: IIf([Spin] Is Not Null,([Spin]+#03:30:00#))

As such it is strange that the majority of records work when the >= is used and for those that don't they then work when <= and the ones that were working are then blank.
 
Upvote 0
Having googled elsewhere the resolution the issue was to go from

This:
WashTime: IIf([Spin] Is Not Null,([Spin]+#03:30:00#))

To This:
CDate(WashTime: IIf([Spin] Is Not Null,([Spin]+#03:30:00#)))
 
Upvote 0
Solution
Really?
I would have thought
Code:
WashTime:CDate(IIf([Spin] Is Not Null,([Spin]+#03:30:00#)))
would be more appropiate?

Still not sure why no False part is not present, when the docs say Required.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,109
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top