7 Replies Latest reply: Sep 8, 2016 12:21 PM by Stefan Wühl

# 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.

• ###### Re: Change Weekend in NetWorkDays Function

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

• ###### Re: Change Weekend in NetWorkDays Function

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!

• ###### Re: Change Weekend in NetWorkDays Function

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.

• ###### Re: Change Weekend in NetWorkDays Function

Thanks Stefan,

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

• ###### Re: Change Weekend in NetWorkDays Function

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

• ###### Re: Change Weekend in NetWorkDays Function

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.