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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If statement problem.

Hi!

I have 2 listboxes with timestamps, HH:MM. Open and Close.

I want to check the current time to see if the store is open and or closed. So i want to return a 0 or 1.

This is my expression: if(time(now(1))>Open AND time(now(1))<Close, 1, 0)

But it does not work.

It shows 0 when the open is 11:00 and close is 23:00 and now the time(now) = 10:47

Thanks!!

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

You cann't use Time as it is

if(time(Frac(now(1)))>Open AND time(Frac(now(1)))<Close, 1, 0)


Becuase Time function internally it keeps the date value too.


If this didn't works, could you please tell how your storing the time range in Open and Close?

View solution in original post

11 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The expression looks OK, but it will only work in a chart/table expression or you have made selections so that no more than 1 possible open and close value (for each row in a chart).

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jsingh71
Partner - Specialist
Partner - Specialist

Can you let me know, In which format you are having Open and Close Time.

jsingh71
Partner - Specialist
Partner - Specialist

And also can you share some sample data.

--Jai

tresesco
MVP
MVP

Are you considering A.M/P.M in now()?

CELAMBARASAN
Partner - Champion
Partner - Champion

You cann't use Time as it is

if(time(Frac(now(1)))>Open AND time(Frac(now(1)))<Close, 1, 0)


Becuase Time function internally it keeps the date value too.


If this didn't works, could you please tell how your storing the time range in Open and Close?

Not applicable
Author

That works! Thanks!

Not applicable
Author

No since im living in Sweden we don't use AM/PM

Not applicable
Author

HH:MM

Not applicable
Author

One more question.

I have the 2 listboxes with PRU and AREA.

If i want a chart to show if(time(Frac(now(1)))>Open AND time(Frac(now(1)))<Close, 0, 1) but only for PRU A and AREA A how can i hardcode this into my if statement?

Thanks!