Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Welcome to our newly redesigned Qlik Community! Read our blog to learn about all the new updates: READ BLOG and REPORTED ISSUES
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Calculate Date-Time Interval without considering weekend.


id

Start Date

End Date

A13/07/2017  05:01:1514/07/2017 03:10:12
B14/07/2017 02:12:40

17/07/2017 01:10:30

C18/07/2017 04:05:1220/07/2017 02:15:30

In Above Scenario

I want to calculate the interval between ID's,

1) in case of ID "A" we can directly calculate date-time Interval as there's no weekend or holiday.

2) but in case of ID "B" start date is 14/07/2017 i.e Friday and end date is 17/07/2017 i.e Monday so there's weekend between dates.

so how to calculate date-time Interval without considering weekend.

3) and In case of ID "C" suppose there is Holiday on 19/07/2017, so how to calculate date-time Interval without considering holiday.

8 Replies
Master III
Master III

Creator
Creator

Hi Pradnya,

Just try using below method:

networkdays (start_date, end_date [, holiday])


Thanks,

Sateesh

Contributor III
Contributor III

Thank you for suggestion, but i want to calculate with time so not getting correct result.

Contributor III
Contributor III

Thank you, I will try and let you know.

Master III
Master III

NetWorkDays(Date([Start Date]),Date([End Date]))

and Set Variables in Script according Your Source Date Format

SET DateFormat='DD/MM/YYYY';
SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

Contributor III
Contributor III

id

StartDate

EndDate

A

01/01/2017 10:11:44

02/01/2017 12:11:44

B

02/01/2017 10:11:44

03/01/2017 05:11:44

C

03/01/2017 10:11:44

04/01/2017 01:11:44

D

04/01/2017 10:11:44

05/01/2017 02:11:44

E

05/01/2017 10:11:44

06/01/2017 03:11:44

F

06/01/2017 10:11:44

07/01/2017 03:11:44

G

07/01/2017 10:11:44

08/01/2017 04:11:44

H

06/01/2017 10:11:44

09/01/2017 15:11:44

I

09/01/2017 10:11:44

10/01/2017 06:11:44

Here in above eg we need to find TAT between EndDate and StartDate.I need to exclude saturday ,sunday and holidays.

Above timings are in date and time .We need the TAT in exact days and time.

There is an 'id' in the above data having StartDate 06/01/2017 10:11:44 and EndDate 09/01/2017 15:11:44. In between these days there are sat and sunday.

According to me whatever the time difference will be there we need to exclude 48hrs of sat n sunday and display the output .Output will be 3 days 5hrs . And if we exclude sat and sunday 1 day 5 hrs.


Kindly suggest and help


Master III
Master III

Try this

LOAD *,
If(EndDate-StartDate >= NetWorkDays(StartDate,EndDate),
Interval(EndDate-StartDate - NetWorkDays(StartDate,EndDate),'D hh:mm'),
Interval(Fabs(EndDate+1-StartDate - NetWorkDays(StartDate,EndDate)),'hh:mm')) as TAT Inline [
id,StartDate,EndDate
A,01/01/2017 10:11:44,02/01/2017 12:11:44
B,02/01/2017 10:11:44,03/01/2017 05:11:44
C,03/01/2017 10:11:44,04/01/2017 01:11:44
D,04/01/2017 10:11:44,05/01/2017 02:11:44
E,05/01/2017 10:11:44,06/01/2017 03:11:44
F,06/01/2017 10:11:44,07/01/2017 03:11:44
G,07/01/2017 10:11:44,08/01/2017 04:11:44
H,06/01/2017 10:11:44,09/01/2017 15:11:44
I,09/01/2017 10:11:44,10/01/2017 06:11:44]
;

Regards,

Antonio

Creator III
Creator III

Dear Pradnya ,

PFA