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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparing timestamps and convert to work-hours. Help?

Hi,

I need to make a large number of calculations with timestamps. Example is the following situation:

Workhours are (always) from 08:00 tm 17:30.

Timestamp1: 20.06.2011 16:00 uur
Timestamp2: 21.06.2011 09:00 uur

Workhours should result in 2,5 uur.

How do I calculate this with a qlikview fomula? (So all times between 17:30 and 08:00 should be excluded).

Has any of you handles this before, and how?

Thanks a lot!

1 Solution

Accepted Solutions
Not applicable
Author

I have managed to solve the issue, based on an excel example on this site http://chandoo.org/wp/2010/09/10/working-hours-formula/.

The sollution is as follows:

//$1 WorkDayStart. Format 9, 9.5, 21
//$2 WorkDayEnd.Format 9, 9.5, 21
//$3 TimeStampStart. Format DateTime
//$4 TimeStampEnd. Format DateTime

Set fxCalcWorkHours = (($2-$1)*NetWorkDays($3,$4))  -(24*(  FMOD($3,1)  -($1/24)  +($2/24)  -FMOD($4,1) ));

So you can load it into a table with the command:


Load *,

$(fxCalcWorkHours(9,18,StartDateTime, EndDateTime) as WorkHoursSpent;

Cheers, Mark

View solution in original post

1 Reply
Not applicable
Author

I have managed to solve the issue, based on an excel example on this site http://chandoo.org/wp/2010/09/10/working-hours-formula/.

The sollution is as follows:

//$1 WorkDayStart. Format 9, 9.5, 21
//$2 WorkDayEnd.Format 9, 9.5, 21
//$3 TimeStampStart. Format DateTime
//$4 TimeStampEnd. Format DateTime

Set fxCalcWorkHours = (($2-$1)*NetWorkDays($3,$4))  -(24*(  FMOD($3,1)  -($1/24)  +($2/24)  -FMOD($4,1) ));

So you can load it into a table with the command:


Load *,

$(fxCalcWorkHours(9,18,StartDateTime, EndDateTime) as WorkHoursSpent;

Cheers, Mark