Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
Not applicable

Add networkdays (working days) to an existing date

Hi there

I have a field called (DocDate).

How can I add 10 working days (networkdays) to this date given by (DocDate)?

Thank you

Tags (1)
1 Solution

Accepted Solutions
wimzjeraar
New Contributor II

Add networkdays (working days) to an existing date

There's a function for this in QlikView:

lastworkdate( start_date, no_of_workdays {, holiday} )

Returns the earliest ending date to achieve number_of_workdays (Monday-Friday) if starting at start_date taking into account any optionally listed holidays. Start_date and number_of_workdays should be valid dates or timestamps.

Examples:

lastworkdate ('2007-02-19', 9) returns '2007-03-01'
lastworkdate ('2006-12-18', 8, '2006-12-25', '2006-12-26') returns '2006-12-29'



6 Replies
danielrozental
Honored Contributor II

Add networkdays (working days) to an existing date

It can probably can be improved

if(weekday(Date+10+(10-Networkdays(Date,Date+10)))=0,Date+10+(10-Networkdays(Date,Date+10))+1,

if(weekday(Date+10+(10-Networkdays(Date,Date+10)))=5,Date+10+(10-Networkdays(Date,Date+10))+2,

Date+10+(10-Networkdays(Date,Date+10))

)

)



danielrozental
Honored Contributor II

Add networkdays (working days) to an existing date

Much simpler

Date + 10 +

if(weekday(Date)=6,2,

if(weekday(Date)=0,1,

3))



wimzjeraar
New Contributor II

Add networkdays (working days) to an existing date

There's a function for this in QlikView:

lastworkdate( start_date, no_of_workdays {, holiday} )

Returns the earliest ending date to achieve number_of_workdays (Monday-Friday) if starting at start_date taking into account any optionally listed holidays. Start_date and number_of_workdays should be valid dates or timestamps.

Examples:

lastworkdate ('2007-02-19', 9) returns '2007-03-01'
lastworkdate ('2006-12-18', 8, '2006-12-25', '2006-12-26') returns '2006-12-29'



MVP
MVP

Add networkdays (working days) to an existing date

Lastworkdate() may be all you need. If it's not enough, I have and can post a couple examples that may help. One loads the holiday list from a table instead of requiring you to type them all in the expression. Another deals with cases where you might work on a weekend day, so want to include some of them. Both may be more complicated than you require.

Not applicable

Add networkdays (working days) to an existing date

Thanks guys.

It worked perfectly. It gave me exactly what I wanted. It gave me a duedate that is generated by taking the document date & adding 10 working days. I used the following in my script.

lastworkdate

(DocDate,10) as PODueDate





yanivbm88
Contributor

Re: Add networkdays (working days) to an existing date

Hi Wim,

How would you set which weekdays should be referred as working days?

I understood the default is Monday-Saturday, but how can I change it to Sunday-Friday?

I tried modifying FirstWeekDay attribute with no success.