# 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.<br><br>Example: `  '25/12/2013', '26/12/2013' `<br><br>You can exclude more than one holiday period, separated by commas.<br><br>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 |