Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Question about getting minutes from timestamps using TIME(FRAC()

Hello,

Thanks in advance for help!

I'm trying to write an expression where I'm checking a Scheduled start time (SCHED_START_TIME) vs. patient in the room time (PiR_DATE_TIME); if the latter is later, I would get the difference of the times in minutes, otherwise, it would be 0.

The expression I have below is not working - I get an error in calculation (have tried several variations to no luck)

if(time(frac(SCHED_START_TIME)) > time(frac(PiR_DATE_TIME)), time(frac(SCHED_START_TIME) - time(frac(PIR_DATE_TIME), 0)

(I would add an "AND" comparing end times as well).

The current "In Block" is good but the "Out Block" isn't always correct in the application so am trying to overwrite it.

      

THE Sched StartTHE Sched StopPt In RmPt Out RmDurationTot Sched BlockIn BlockOut Block
33040
11/07/2014 08:0011/07/2014 11:0011/07/2014 08:0011/07/2014 09:541142401140
11/21/2014 08:0011/21/2014 10:3011/21/2014 07:5711/21/2014 10:191422401393
11/21/2014 10:3011/21/2014 12:5011/21/2014 10:4311/21/2014 12:371142407737
14 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Are you sure all your fields are loaded as Timestamps? Put them in listboxes and change the Number format to Fixed to 4 places. Do they all look like decimal numbers eg 40234.02567?

-Rob

wardzynski
Creator
Creator

Karen,

How did you get the duration in minutes, the difference between 2 timestamp in minutes?

Would be interesting to know!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

One day = 1. You can multiply the difference by 1440 (the number of minutes per day) or my preferred method, use the Interval function.

Interval(myduration, 'm')

so

Interval(0.5, 'm') = 720

-Rob

wardzynski
Creator
Creator

Thank you for that clear explanation, Rob!
I saw you also used the rangemax function, was that to be able to count null() values included in the interval range?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The RangeMax function was used in the original thread because the OP had some missing data and wanted to ensure the duration was never less than zero -- which would have been invalid in this case.

-Rob