If then statement with Time involved

latex88

Registered User.
Local time
Today, 02:06
Joined
Jul 10, 2003
Messages
198
I would like to assign a field with a variable depends on the time stored in a text box. The value of the text box is assigned by "=now()" and is based on when the form containing the text box is filled.

In my query, how would I write the expression if I want to, for example, assign the field based on the time listed in the text box if it's between 10:00am and 4:00pm to "Day" and from 4:01pm to 11:00pm to "Night"?

Thanks for the help.
 
IIf(CDate(Format([Forms]![formName]![textboxName],"Long Time")) Between #10:00:00 AM# And #4:00:00 PM#, "Day", IIf(CDate(Format([Forms]![formName]![textboxName],"Long Time")) Between #4:00:01 PM# And #11:00:00 PM#, "Night", Null))


(replace with the correct form name and text box name)
 
Last edited:
Anotherway:

iif(cdate(format(#21-10-2003 16:00# - Cdate("10:00:00"),"HH:NN"))<= cdate("06:00:00"),"Day","Night")

Regards

The Mailman
 

Users who are viewing this thread

Back
Top Bottom