I try to compare time in conditional response:
if $sys.func.IDENTITY($sys.func.FORMAT_DATE($sys.func.NOW(), "H")) < 8 OR $sys.func.IDENTITY($sys.func.FORMAT_DATE($sys.func.NOW(), "H")) > 20
We are closed now
else
We are open
endif
Time is 18:20, and I added $sys.func.IDENTITY($sys.func.FORMAT_DATE($sys.func.NOW(), "H"))
to the text output and made sure it says "18", but it keeps saying "We are closed now".
I see that "18" is of string type. I might need to convert the value to integer, but how?
Working hours are between 8am-9pm
How to properly compare?
The right hand side is type casted to the same type as the left hand side before comparing.
Said this, I think that you can use “HH” to make sure you have a leading zero, since there could be a non-numeric “:mm” minute part.
You can use the following code:
if $sys.func.FORMAT_DATE($sys.func.NOW(), "HH") < “08” OR $sys.func.FORMAT_DATE($sys.func.NOW(), "HH") > “20”
We are closed now
else
We are open
endif