# DateTime Query



## liammoohan

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):






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!?!





Any assistance in figuring this out would be much appreciated.


----------



## Joe4

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.


----------



## liammoohan

Joe4 said:


> 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.


----------



## welshgasman

Why is there no FalsePart?
All parts are required?








						IIf function (Visual Basic for Applications)
					

Office VBA reference topic



					learn.microsoft.com


----------



## liammoohan

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#)))


----------



## welshgasman

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.


----------

