Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Change Weekend in NetWorkDays Function

Hello everyone!

Is it possible to change the weekend of the function Networkdays by passing a parameter or something like that? Our weekend is Friday and Saturday, and the default of Qlik Sense is Saturday and Sunday. I tried changing FirstWeekDay to the following:

SET FirstWeekDay=6;

Also changed the Daynames but with no luck, Sunday gets excluded from the calculation.

I found a few solutions such as NetworkingDays(DateA+1, DateB+1) but it gives incorrect numbers.

Your help is appreciated!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Yes, it does take both start and end date into account:


The networkdays function returns the number of working days (Monday-Friday) between and including start_date andend_date taking into account any optionally listed holiday.

Hence, to exclude start date, add another +1 to this date.

View solution in original post

8 Replies
swuehl
MVP
MVP

Could you post a sample where Networkdays(StartDate + 1, EndDate+1) returns incorrect numbers and what you expect to see instead?

Anonymous
Not applicable
Author

Hey Stefan!

Using the function with the following days:

26-7-2015 and 28-7-2015 returns 3 instead of 2. Unless it calculates the start date as well?

Thanks Stefan!

swuehl
MVP
MVP

Yes, it does take both start and end date into account:


The networkdays function returns the number of working days (Monday-Friday) between and including start_date andend_date taking into account any optionally listed holiday.

Hence, to exclude start date, add another +1 to this date.

Anonymous
Not applicable
Author

Thanks Stefan,

Is it possible to return the time in minutes not days?

swuehl
MVP
MVP

A day has 24*60 minutes, so maybe just multiply by this number?

Anonymous
Not applicable
Author

Thanks Stefan

My issue is what if the number returned is ZERO? as subtracting 1 will eliminate a full working day; in addition, even by not subtracting one, the result is kind of inaccurate as well (i.e. assuming an employee finishes a task within an hour, it will be calculated as a full working day and worse if the task goes to two different employees, Emp1 finished and then the task goes to Emp2 who also finished within the same day the function will calculate 2 working days instead of 1) That is why I was asking about actual minutes not converting days to minutes. By the way I am using the function at each step of an application history (Now I kind of think that it can not be used like this) and the reason is because I don't calculate steps where an application is returned to the applicant.

Wishing for your feedback!

swuehl
MVP
MVP

That's hard to answer without knowing the details of your data model.

SumitgargIBI
Contributor
Contributor

Can you please tell how to include Saturday in working days.