Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Folks,
How do I compare Time in an if-else statement? In other words, how would I do the following:
If( Time(Now()) > 10:30AM, 'Y', 'N' )
I should probably know this by now, but I can't find a simple way to do it other than to do a bunch of Now() - Floor(Num(Now())) gynmanstics which has a code-smell.
I really just want to know if the time a report is generated/rendered is after 10:30AM and other times of day.
Any help is greatly appreciated.
If(Time(Now()) > Time#('10:30 AM', 'h:mm tt'), 'Y', 'N')
Adjust the time format in the Time#() function to match the format of your constant time if needed.
If(Time(Now()) > Time#('10:30 AM', 'h:mm tt'), 'Y', 'N')
Adjust the time format in the Time#() function to match the format of your constant time if needed.
One thing to note, is that the Time(Now()) function call still has the month, year, and date in the Num value. So the value it's comparing to is 45XXX vs. 0.94.
The trick around this is to subtract the Num value of the day start. Below is my final solution thanks to @Aasir putting me on the right track.
If(Time(Now()-DayStart(Today())) > Time#('10:30 PM', 'h:mm tt'), 'Y', 'N')