Hi All,
I have to check whether the current time(irrespective of any user time zone) is between 7pm EST to 9am EST.
So we tried to convert the current time to EST first and then to compare it with "7:00 PM" & "9:00 AM" EST (by creating text constant).
We just tested with below code to check whether comparison works fine by changing the constant value, but it fails
totime(
gmt(
local(now(), "EST" ) ) ) > totime(cons!xyz)
where cons!xyz = "7:00 PM" (a text constant)
So please help me how to make this work. Thanks in advance.
Discussion posts and replies are publicly visible
Why do you convert the time back and forth? Appian internally works with UTC only and converts any timestamp from/to the users timezone automatically. Storing a time as a text is also a difficult decision.
and( hour(now()) >= 7, hour(now()) <= 21 )
Hi Stefan, thanks for your response. I got your point and tried testing with the above code, but it is not giving me the expected result. Please correct me if I am wrong.
My appian time zone is IST, and current time is 9:42 PM, but hour(now()) gives me output as 16 instead of 21,please refer the below screenshot,
That is expected. Be aware that calling now() in the expression editor evaluates it in UTC by default. When called normally it uses the users timezone as configured in the user settings.
Appian is pretty good in making time just work.
Can you please tell me,will this work if I create an expression rule for the above code and configure it in xor gateway in process model?
That should work as the process instance will inherit the timezone of the initiator and evaluate that expression accordingly.
Do your own small test.
Okay got it. Yes, we will do our testing. Thanks for your help!!