If() expression question

OK Im sure I have just stared at this too long but, Im curious about a return from an If statement I am using:

I have this expression tag, Current Shift:

if(21 > (dateFormat({[System]Gateway/CurrentDateTime}, "k")) >7,0,1) 

returning a 1.
From there that tag is bound to a label, Current Shift Ind 2, showing its a 1.

Then another label binds to that labels .value and has a expression:

if({../Current Shift Ind 2.props.value}=1,'DAY','NIGHT')

but is returning 'NIGHT' instead of 'DAY'

Am I crazy? BTW, I am troubleshooting an old project from who knows who.

I was told before, that it worked and should be displaying 'DAY'. Im sure there are lots of thoughts, lol, but any help?

I tested that logic on my end and it works. Perhaps try to change the binding of Day/Night label to use the exact same logic as the first. I have seen funky things like this happend on rare occasions.

dateFormat() produces a string, not an integer. Comparing strings with integers is probably the issue.

1 Like

Would this be more like right? Since I would be comparing string to string..

timeBetween(dateFormat({[System]Gateway/CurrentDateTime}, "k"), "8", "20")//Boolean ON = Day

Is there any particular reason you are avoiding getHour() ?

getHour({[System]Gateway/CurrentDateTime}) >= 8 && getHour({[System]Gateway/CurrentDateTime}) <= 20

Sure was, I didnt notice it there in the listing. I see it now, lol. Thanks very helpful sir.