Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
wimzjeraar
Contributor II
Contributor II

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'



View solution in original post

6 Replies
danielrozental
Master II
Master II

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
Master II
Master II

Much simpler

Date + 10 +

if(weekday(Date)=6,2,

if(weekday(Date)=0,1,

3))



wimzjeraar
Contributor II
Contributor II

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'



johnw
Champion III
Champion III

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
Author

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
Creator
Creator

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.