Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
josephinetedesc
Contributor III

Networkdays function

Hi - to give an example of what I mean:

datestamp 1     1/1/2016 9:00 am

datestamp 2     1/1/2016 9:30 am

if I use the function

Networkdays(datestamp1, datestamp2) - the answer is 1

if I use sum(timestamp2 - timestamp1) -  the answer is 0.0 something.

I have been asked to show Networking days as 0 - if the two timestamps occur on the same days.  Simple formula:

Networkdays(datestamp1, datestamp2) -1

But - working on some scenarios of dates - there is a problem when timestamp2 occurs on a Saturday.

for example:

Tuesday 7/06/2016  2:00:00 PM  and  Saturday11/06/2016  3:00:00 PM

    

dateCTdateQAanswerNetwork days
Wednesday, 1 June 2016Wednesday, 1 June 20160.0416666671
Wednesday, 1 June 2016Thursday, 2 June 20161.0416666672
Tuesday, 7 June 2016Friday, 10 June 20163.0416666674
Tuesday, 7 June 2016Saturday, 11 June 20164.0416666674
Wednesday, 1 June 2016Wednesday, 1 June 20160.0013888891

(NetworkDays -1) will give 3 days which is not correct.

Will this problem only occur when timestamp2 is a weekend date?

Will I need to have another formula to account for these occassions?

Thank you

Jo

Tags (1)
7 Replies
Not applicable

Re: Networkdays function

Hi Josephine,

Why don't you simply use

(dateQA-dateCT)+1

I don't think you need NetworkDays here.

josephinetedesc
Contributor III

Re: Networkdays function

Hi Ramkumar

the problem is that work does not occur on weekends (so far at leat in Australia for some industries

So we need to take this into account.

jo

pavan045
New Contributor III

Re: Networkdays function

Try below expression

if(Date(Timestamp1) = Date(Timestamp2),

                     NetworkDays(Timestamp1, Timestamp2) - 1,

                              NetworkDays(Timestamp1, Timestamp2))

Hope this helps

Thank you

Re: Networkdays function

Hi,

try with simple if else

like if(floor(datestamp1)=floor(datestamp2),1,Networkdays(datestamp1, datestamp2))

Note: in comparision convert your timestamp value to date

for example

datestamp 1     1/1/2016 9:00 am convert to 1/1/2016

datestamp 2     1/1/2016 9:30 am convert to 1/1/2016

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
josephinetedesc
Contributor III

Re: Networkdays function

Timestamp1 is to the 100th millisecond, if I could get the timestamp to the nearest second rather than the 100th of a second that might work.  I tried date(Timestamp1, 'mm/DD/yyyy') as newDate  but Qlikview seemed to remember the "rest" of the date - I need to check this.  Whether the conversion is just "looks" or if the number is actually changed.  Will check on Monday.

Max Dreamer - is there a way of keeping the timestamp to the nearest minute?  In another situation I have a series of events that occur within a number of milliseconds of each other.  I want to group them together if they occur within the same minute.  I will start another discussion.

Jo

Not applicable

Re: Networkdays function

Hi Josephine,

can you please have a look at this.

How to remove weekend and holidays from your calculation

Re: Networkdays function

Hi,

in format attribute

mm denotes minutes

MM denotes Months

modify your expression and try.

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Community Browser