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: 
Michiel_QV_Fan
Specialist
Specialist

Networkdays wrong from script, correct in UI

I calculate networkdays in the script but the results are wrong while using the same dates in a table in the UI are calculated correct.

These 2 dates:  20/3/2018 to 11/4/2018

calculated in the script as 22 days

and in the UI as 17 days

17 Days is correct.

Dates are loaded in this format 20.03.2018 but changed with this statement: date(date#(<datefields>,'DD.MM.YYYY')'DD/MM/YYYY')

I need the calculation in the script.

QlikView 12 SR3 versio 12.20.20400.0

1 Solution

Accepted Solutions
rubenmarin

It should, and this works too:

LOAD NetWorkDays(Date(date#('20.03.2018', 'DD.MM.YYYY'),'DD/MM/YYYY'),Date(date#('11.04.2018', 'DD.MM.YYYY'),'DD/MM/YYYY')) as value

AutoGenerate 1;

That's why I'm askjing for a sample, there should be something else, I'm not sure if the different version is the only reason.

View solution in original post

7 Replies
rubenmarin

Hi Michiel, I make a document with this script:

LOAD NetWorkDays('20/03/2018','11/04/2018') as value

AutoGenerate 1;

value loads '17'. Can you post a sample that shows the problem, I can't reproduce it (I'm in different version)

Michiel_QV_Fan
Specialist
Specialist
Author

See original post for the example.

I tried this also and hardcoded dates in the correct format does calculate correct.

But I expect qlikview to do the same with the date fields that are edited with date and date# functions.

sasiparupudi1
Master III
Master III

NetWorkDays(Date#('20.03.2018','DD.MM.YYYY'),Date#('11.04.2018','DD.MM.YYYY')) gives me 17

rubenmarin

It should, and this works too:

LOAD NetWorkDays(Date(date#('20.03.2018', 'DD.MM.YYYY'),'DD/MM/YYYY'),Date(date#('11.04.2018', 'DD.MM.YYYY'),'DD/MM/YYYY')) as value

AutoGenerate 1;

That's why I'm askjing for a sample, there should be something else, I'm not sure if the different version is the only reason.

Michiel_QV_Fan
Specialist
Specialist
Author

I do not have just 2 dates, the 2 dates mentioned are just examples.

I have 2 fields with all the dates.

Michiel_QV_Fan
Specialist
Specialist
Author

Strange why setting the date formats inside the networkdays function does the trick.

I did a preceding load thus calling the edited date formats and that does not work.

Do you know why?

rubenmarin

Preceding load also returns me '17'. I tried with:

LOAD NetWorkDays(Date1,Date2) as value;

LOAD

Date(date#('20.03.2018', 'DD.MM.YYYY'),'DD/MM/YYYY') as Date1,

Date(date#('11.04.2018', 'DD.MM.YYYY'),'DD/MM/YYYY') as Date2

AutoGenerate 1;

I tried a few things the retrive that '22' but I didn't accomplish, the only way is doing Date2-Date1, so that 22 it's counting all dates, not removing weekends.