NETWORKDAYS
The working days from one date to another, both counted, with a choice of weekend days and a table of holidays.
Group: Date and time. Compatible with DAX.
Syntax
NETWORKDAYS ( <start_date>, <end_date> [, <weekend>] [, <holidays>] )
| Parameter | Type | Description |
|---|---|---|
start_date | Date | The first day of the period; it counts when it is a working day. |
end_date | Date | The last day of the period; it counts too. |
weekend | Whole number optional | Which days are the weekend: 1 Saturday and Sunday (when left out), 2 Sunday and Monday, and so on to 7 Friday and Saturday; 11 Sunday alone, 12 Monday alone, and so on to 17 Saturday alone. |
holidays | Table optional | A table of one column of dates that are not working days. |
Returns
Whole number. How many working days there are from the start to the end, both ends counted.
Remarks
- From a Monday to the same Monday is 1; from a Saturday to itself, 0.
- A start after the end counts backwards and gives a negative number.
- The time of day of either date plays no part.
- A holiday on a weekend day is not taken off twice, and neither is a date listed twice.
- Leave the weekend out with two commas to give holidays only:
NETWORKDAYS ( start, end, , holidays ). - A blank date is taken as 30 December 1899, so a blank start counts every working day since then: check for blanks first. With both dates blank the result is BLANK.
- A weekend number other than 1 to 7 or 11 to 17 is an error.
Examples
Working days in March 2024, three ways
EVALUATE
ROW (
"Saturday and Sunday", NETWORKDAYS ( DATE ( 2024, 3, 1 ), DATE ( 2024, 3, 31 ) ),
"Friday and Saturday", NETWORKDAYS ( DATE ( 2024, 3, 1 ), DATE ( 2024, 3, 31 ), 7 ),
"Sunday alone", NETWORKDAYS ( DATE ( 2024, 3, 1 ), DATE ( 2024, 3, 31 ), 11 )
)
| Saturday and Sunday | Friday and Saturday | Sunday alone |
|---|---|---|
| 21 | 21 | 26 |
With Easter off
Maundy Thursday and Good Friday fell on 28 and 29 March in 2024.
EVALUATE
VAR Holidays =
DATATABLE ( "Day", DATETIME, { { "2024-03-28" }, { "2024-03-29" } } )
RETURN
ROW ( "Working days", NETWORKDAYS ( DATE ( 2024, 3, 1 ), DATE ( 2024, 3, 31 ), , Holidays ) )
| Working days |
|---|
| 19 |
A price for every weekday
Each commodity has a price on every working day from its first to its last.
EVALUATE
SUMMARIZECOLUMNS (
Prices[Commodity],
"Days with a price", COUNTROWS ( Prices ),
"Weekdays", NETWORKDAYS ( MIN ( Prices[Date] ), MAX ( Prices[Date] ) )
)
ORDER BY Prices[Commodity]
| Prices[Commodity] | Days with a price | Weekdays |
|---|---|---|
| Aroma hops | 771 | 771 |
| Malting barley | 771 | 771 |