working days, weekend days, holidays, working day holidays, weekend holidays
This function returns the number of working days / weekend days / holidays between two dates.
Function Name | Description |
---|---|
working days | All working days are counted. Specified holidays lying on working days will be subtracted. |
weekend days | All weekend days are counted. All specified holidays are ignored. |
holidays | All specified holidays are counted, regardles of day of week. |
working day holidays | All specified holidays lying on working days are counted. |
weekend holidays | All specified holidays lying on weekend days. |
1-2
No. | Type | Description |
---|---|---|
1 input |
date or string converted to date | Start date Counting begins with this date. All days are counted in full. Any time info will be ignored, even if a late evening hour is specified. |
2 input |
date or string converted to date | Finish date Counting ends with this date. All days are counted in full. Any time info will be ignored, even if an early morning hour is specified. 0 is returned if the finish date lies before the start date. |
Opt. 3 input |
set | Week pattern This parameter defines the nature of the working days. Following rules aply:
Example: { 0.5, 1, 1, 0, 0, 0, 0 } is a possible week pattern for a 50% part time employee.
|
Opt. 4 input |
set | Full-day holidays The set should contain holiday dates. The contents may be located anyhwere inside the set, even if nested and mixed with other non-date data.
The dates will be extracted automatically using the same functionality as in find dates().
Holidays are subtracted in full (1 / holiday) if they lie on declared weekdays, for example Memorial Day and Easter Monday.
No holidays are considered if no dates are specified. Repeated holiday dates will be ignored.
|
Opt. 5 input |
set | Half-day holidays The set should contain holiday dates. The contents may be located anyhwere inside the set, even if nested, even if nested and mixed with other non-date data.
The dates will be extracted automatically using the same functionality as in find dates().
Holidays are subtracted in half (0.5 / holiday) if they lie on declared weekdays, for example the Zürich Monday afternoon holiday Sechseläuten.
No holidays are considered if no dates are specified. Repeated holiday dates, as well as dates already specified as full-day holidays, will be ignored.
|
Opt. 6 input |
string | Options Following options apply:
|
table initialize( fd holidays, // Applicable to Zürich / Switzerland
{ { fd holidays, Dates },
{ New Year, "2025-01-01", "2025-01-02", "next year:", "2026-01-01", "2026-01-02" },
{ Easter Weekend, "2025-04-18", "2025-04-20", "2025-04-21", "2026-04-03", "2026-04-05", "2026-04-06" },
{ Labor Day, "2025-05-01", "", "", "2026-05-01" },
{ Pentecost Weekend, "2025-06-08", "2025-06-09", "... and", "2026-05-24", "2026-05-25" },
{ Ascension Day, "2025-05-29", "", "", "2026-05-14" },
{ National Holiday, "2025-08-01", "", "", "2026-08-01" },
{ Christmas, "2025-12-25", "2025-12-26", "", "2026-12-25", "2026-12-26" } } );
table initialize( hd holidays,
{ { hd holidays, Dates },
{ Zürich City Holidays, "2025-04-28", "2025-09-15", "... and", "2026-04-17", "2026-09-14" },
{ Year-End Holidays, "2025-12-24", "2025-12-31", "", "2026-12-24", "2026-12-31" } } ) ;
table list( fd holidays );
table list( hd holidays );
// Full year Easter weeks City holiday 6 days 7 days H'day on THU, Christmas , previous year
start[] = { "2025-01-01", "2025-04-14", "2025-04-28", "2025-09-01", "2025-09-01", "2025-05-26", "2025-12-01", "2024-01-01" };
end [] = { "2025-12-31", "2025-04-27", "2025-04-28", "2025-09-06", "2025-09-07", "2025-06-01", "2025-12-01", "2024-12-31" };
mon_thru_fri[] = { 5:1,2:0 };
mon_wed_fri[] = { 1,0,1,0,1,0,0 };
50 pct[] = { 5:0.5,2:0 };
// [full day holdays:,] references the entire table where the dates are extracted automatically. All text contents are ignored.
// For simplicity, the functions below are called with vectorization to process several dates at once.
echo("Working days : ", working days ( start[], end[], mon_thru_fri[] ) );
echo("Weekend days : ", weekend days ( start[], end[], mon_thru_fri[] ) );
echo("Weekend days (same qty) : ", weekend days ( start[], end[], mon_thru_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Working days minus holidays: ", working days ( start[], end[], mon_thru_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("All holidays : ", holidays ( start[], end[], mon_thru_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Holidays on working days : ", working day holidays( start[], end[], mon_thru_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Holidays on weekend days : ", weekend holidays ( start[], end[], mon_thru_fri[], [fd holidays:,], [hd holidays:,] ) );
echo(new line, "And a part time model: Mon + Wed + Fre only: " );
echo("Working days w/o holidays : ", working days ( start[], end[], mon_wed_fri[] ) );
echo("Weekend days : ", weekend days ( start[], end[], mon_wed_fri[] ) );
echo("Weekend days (same qty) : ", weekend days ( start[], end[], mon_wed_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Working days minus holidays: ", working days ( start[], end[], mon_wed_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("All holidays : ", holidays ( start[], end[], mon_wed_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Holidays on working days : ", working day holidays( start[], end[], mon_wed_fri[], [fd holidays:,], [hd holidays:,] ) );
echo("Holidays on weekend days : ", weekend holidays ( start[], end[], mon_wed_fri[], [fd holidays:,], [hd holidays:,] ) );
echo(new line, "And a part time model: Mon-Fre half days only: " );
echo("Working days w/o holidays : ", working days ( start[], end[], 50 pct[], '', '', partial ) );
echo("Weekend days : ", weekend days ( start[], end[], 50 pct[], '', '', partial ) );
echo("Weekend days (same qty) : ", weekend days ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], partial ) );
echo("Working days minus holidays: ", working days ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], partial ) );
echo("All holidays : ", holidays ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], partial ) );
echo("Holidays on working days : ", working day holidays( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], partial ) );
echo("Holidays on weekend days : ", weekend holidays ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], partial ) );
echo(new line, "And a part time model: Mon-Fre half days only, but treated as full days: " );
echo("Working days w/o holidays : ", working days ( start[], end[], 50 pct[], '', '', partial ) );
echo("Weekend days : ", weekend days ( start[], end[], 50 pct[], '', '', partial ) );
echo("Weekend days (same qty) : ", weekend days ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], full ) );
echo("Working days minus holidays: ", working days ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], full ) );
echo("All holidays : ", holidays ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], full ) );
echo("Holidays on working days : ", working day holidays( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], full ) );
echo("Holidays on weekend days : ", weekend holidays ( start[], end[], 50 pct[], [fd holidays:,], [hd holidays:,], full ) );
0 : fd holidays | Dates | | | | |
1 : New Year | 2025-01-01 | 2025-01-02 | next year: | 2026-01-01 | 2026-01-02 |
2 : Easter Weekend | 2025-04-18 | 2025-04-20 | 2025-04-21 | 2026-04-03 | 2026-04-05 | 2026-04-06
3 : Labor Day | 2025-05-01 | | | 2026-05-01 | |
4 : Pentecost Weekend | 2025-06-08 | 2025-06-09 | ... and | 2026-05-24 | 2026-05-25 |
5 : Ascension Day | 2025-05-29 | | | 2026-05-14 | |
6 : National Holiday | 2025-08-01 | | | 2026-08-01 | |
7 : Christmas | 2025-12-25 | 2025-12-26 | | 2026-12-25 | 2026-12-26 |
0 : hd holidays | Dates | | | |
1 : Zürich City Holidays | 2025-04-28 | 2025-09-15 | ... and | 2026-04-17 | 2026-09-14
2 : Year | 2025-12-24 | 2025-12-31 | | 2026-12-24 | 2026-12-31
Working days : {261,10,1,5,5,5,1,262}
Weekend days : {104,4,0,1,2,2,0,104}
Weekend days (same qty) : {104,4,0,1,2,2,0,104}
Working days minus holidays: {249,8,0.5,5,5,4,1,262}
All holidays : {14,3,0.5,0,0,1,0,0}
Holidays on working days : {12,2,0.5,0,0,1,0,0}
Holidays on weekend days : {2,1,0,0,0,0,0,0}
And a part time model: Mon + Wed + Fre only:
Working days w/o holidays : {157,6,1,3,3,3,1,157}
Weekend days : {208,8,0,3,4,4,0,209}
Weekend days (same qty) : {208,8,0,3,4,4,0,209}
Working days minus holidays: {149,4,0.5,3,3,3,1,157}
All holidays : {14,3,0.5,0,0,1,0,0}
Holidays on working days : {8,2,0.5,0,0,0,0,0}
Holidays on weekend days : {6,1,0,0,0,1,0,0}
And a part time model: Mon-Fre half days only:
Working days w/o holidays : {130.5,5,0.5,2.5,2.5,2.5,0.5,131}
Weekend days : {234.5,9,0.5,3.5,4.5,4.5,0.5,235}
Weekend days (same qty) : {234.5,9,0.5,3.5,4.5,4.5,0.5,235}
Working days minus holidays: {123.5,4,0,2.5,2.5,2,0.5,131}
All holidays : {14,3,0.5,0,0,1,0,0}
Holidays on working days : {7,1,0.5,0,0,0.5,0,0}
Holidays on weekend days : {2,1,0,0,0,0,0,0}
And a part time model: Mon-Fre half days only, but treated as full days:
Working days w/o holidays : {130.5,5,0.5,2.5,2.5,2.5,0.5,131}
Weekend days : {234.5,9,0.5,3.5,4.5,4.5,0.5,235}
Weekend days (same qty) : {104,4,0,1,2,2,0,104}
Working days minus holidays: {249,8,0.5,5,5,4,1,262}
All holidays : {14,3,0.5,0,0,1,0,0}
Holidays on working days : {12,2,0.5,0,0,1,0,0}
Holidays on weekend days : {2,1,0,0,0,0,0,0}