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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Sunflower_00
Contributor II
Contributor II

Hours generated

Hi I have created the start time and end time in the load editor script. So I have the min(start time) , min(starttime + 30) in this format (DD/MM/YYYY hh:mm:ss) and the number of hours. I want to know how many hours each ID worked. I tried interval(starttime - endtime, 'hh') and it doesn't give me the right answer.

Labels (2)
1 Reply
cristianj23a
Partner - Creator III
Partner - Creator III

Hi Sunflower,
try this code.

 

// Sample data for WorkLog table
WorkLogTest1:
LOAD * INLINE [
ID, StartTime, EndTime, HoursWorked
1, '28/07/2023 08:00:00', '28/07/2023 10:30:00',
2, '28/07/2023 09:15:00', '28/07/2023 12:45:00',
3, '28/07/2023 13:30:00', '28/07/2023 17:00:00'
];

// Convert StartTime and EndTime to QlikView timestamp format
WorkLogTest2:
LOAD
ID,
Time#(StartTime, 'DD/MM/YYYY hh:mm:ss') as StartTime,
Time#(EndTime, 'DD/MM/YYYY hh:mm:ss') as EndTime
RESIDENT WorkLogTest1;

// Calculate HoursWorked using Interval function
NoConcatenate
WorkLog:
LOAD
ID,
StartTime,
EndTime,
Interval(EndTime - StartTime, 'hh:mm') as HoursWorked
RESIDENT WorkLogTest2;
Drop Table WorkLogTest1,WorkLogTest2;

 

Regarts.

 
https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.