Skip to main content

firstworkdate - script and chart function

The firstworkdate function returns the latest starting date to achieve no_of_workdays (Monday-Friday) ending no later than end_date taking into account any optionally listed holidays. end_date and holiday should be valid dates or timestamps.

Syntax:  

firstworkdate(end_date, no_of_workdays [, holiday] )

Return data type: integer

Arguments:  

FirstWorkDate arguments
Argument Description
end_date The timestamp of end 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:  

firstworkdate ('29/12/2014', 9)

Returns '17/12/2014.

Example 2:  

firstworkdate ('29/12/2014', 9, '25/12/2014', '26/12/2014')

Returns 15/12/2014 because 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 [

EndDate

28/03/2015

10/12/2015

5/2/2016

31/3/2016

19/5/2016

15/9/2016

] ;

NrDays:

Load *,

FirstWorkDate(EndDate,120) As StartDate

Resident ProjectTable;

Drop table ProjectTable;

 

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

Example 3 results
InvID EndDate StartDate
1 28/03/2015 13/10/2014
2 10/12/2015 26/06/2015
3 5/2/2016 24/08/2015
4 31/3/2016 16/10/2015
5 19/5/2016 04/12/2015
6 15/9/2016 01/04/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