Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
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

How to Calculate the difference between timestamp in hrs.

Hi All,

How to Calculate the difference between timestamp in hrs. when my table is in the form of

CaseId PriorityId StageId Time

1          1              1   1/1/2013 11:08:00 AM 

1          1               2     1/1/2013 11:20:00 AM

1          1               3      1/1/2013 12:20:00 AM

Now i need to make a chart where my dimension is a drill down of PriorityId and StageId and in expression i need to calculate the StageId wise expression,

Like for stage Id =1 then in expression the difference between Time of stageId 2 and Time of StageId 1.

and for stage Id =2 then in expression the difference between Time of stageId 3 and Time of StageId 2.

Thanks and Regards.

2 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this script

Temp:

LOAD

CaseId,

PriorityId,

StageId,

Timestamp(Timestamp#(Time, 'M/D/YYYY hh:mm:ss TT'), 'M/D/YYYY hh:mm:ss TT') AS Time

INLINE [

CaseId, PriorityId, StageId, Time

1,1,1,1/1/2013 11:08:00 AM

1,1,2,1/1/2013 11:20:00 AM

1,1,3,1/1/2013 12:20:00 AM ];

Data:

LOAD

CaseId, PriorityId, StageId,

Time,

Interval(Previous(Time) - Time, 'hh') AS Hours

RESIDENT Temp

ORDER BY StageId Desc;

DROP TABLE Temp;

Regards,

Jagan.

Not applicable
Author

Hi Jagan,

Don't you think that calculation of hours is

Interval(Time - Previous(Time) , 'hh') AS Hours

instead of

Interval(Previous(Time) - Time, 'hh') AS Hours.