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: 
alec1982
Specialist II
Specialist II

Compare times

hi all,

trying to compare two times and seem to get wrong results

expression: if(time(FinishTime) <  time(SLA),1,0)

time format used HH:MM:SS

example: finish time is 5:10:59

SLA: 7:00:00

here I should get 1 but getting 0

Anyone knows why?

2 Replies
sunny_talwar

If it is truly read as times by QlikView, you might not even need Time() function.

If(FinishTime < SLA, 1, 0) as Flag

But it seems they are not read as time, so try this:

If(Time#(FinishTime, 'h:mm:ss') < Time#(SLA, 'h:mm:ss'), 1, 0) as Flag

MarcoWedel

I guess your FinishTime and SLA fields are timestamps, i.e. they have an integer date part you have to get rid of to just compare the fractional time part of the timestamp. (The Time() function you used doesn't change the numerical value of your timestamp, it only formats it.)

So one solution might be:

If(Frac(FinishTime) <  Frac(SLA),1,0)


or shorter

-(Frac(FinishTime) <  Frac(SLA))

as boolean true has a value of -1 while false is represented by 0.


hope this helps


regards


Marco