Skip to main content

lastworkdate - script and chart function

The lastworkdate function returns the earliest ending date to achieve no_of_workdays (Monday-Friday) if starting at start_date taking into account any optionally listed holiday. start_date and holiday should be valid dates or timestamps. 

Syntax:  

lastworkdate(start_date, no_of_workdays {, holiday})

Return data type: dual

Arguments:  

Lastworkdate arguments
Argument Description
start_date The start date to evaluate.
no_of_workdays The number of working days to achieve.
holiday

Holiday periods to exclude from working days. A holiday period is stated as a start date and an end date, separated by commas.

Example: '25/12/2013', '26/12/2013'

You can exclude more than one holiday period, separated by commas.

Example: '25/12/2013', '26/12/2013', '31/12/2013', '01/01/2014'

Examples and results:  

These examples use the date format DD/MM/YYYY. The date format is specified in the SET DateFormat statement at the top of your load script. Change the format in the examples to suit your requirements.

Example 1:  

lastworkdate ('19/12/2014', 9)

Returns '31/12/2014'  

Example 2:  

lastworkdate ('19/12/2014', 9, '2014-12-25', '2014-12-26')

Returns '02/01/2015 as a holiday period of two days is taken into account.

Example 3:  

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

ProjectTable:

LOAD *, recno() as InvID INLINE [

StartDate

28/03/2014

10/12/2014

5/2/2015

31/3/2015

19/5/2015

15/9/2015

] ;

NrDays:

Load *,

LastWorkDate(StartDate,120) As EndDate

Resident ProjectTable;

Drop table ProjectTable;

 

The resulting table shows the returned values of LastWorkDate for each of the records in the table.

Example 3 results
InvID StartDate EndDate
1 28/03/2014 11/09/2014
2 10/12/2014 26/05/2015
3 5/2/2015 27/07/2015
4 31/3/2015 14/09/2015
5 19/5/2015 02/11/2015
6 15/9/2015 29/02/2016

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com