Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III
Specialist III

How To Compare Time(Now()) to Constant Time i.e 10:30AM

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.

Labels (4)
1 Solution

Accepted Solutions
Aasir
Creator III
Creator III

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.

 

View solution in original post

2 Replies
Aasir
Creator III
Creator III

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.

 

JustinDallas
Specialist III
Specialist III
Author

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')