# businessDaysBetween

Industry: Core

## Signature

```ts
businessDaysBetween(start: string, end: string, calendar: BusinessCalendar): number | null
```

Count the working days between two local dates, **excluding `start` and including `end`**.

- The convention is stated, not inferred: the range is `(start, end]`. Counting from Monday to Friday of the same week gives 4, not 5 — Monday itself is not counted.
- That makes it the inverse of `addBusinessDays` when `n ≥ 0` or `start` is a business day: if `end` is `addBusinessDays(start, n, calendar)`, this returns `n`. From a weekend or holiday `start`, a negative `n` counts one closer to zero, because `start` itself is excluded and is not a business day.
- `end` before `start` returns a negative count, so swapping the arguments negates the result. An empty range is always `0`, never `-0`, and `businessDaysBetween(d, d, calendar)` is 0 for any `d`.
- The count is computed, not walked, so there is no range limit: whole weeks contribute one of each weekday and only the holidays are visited individually.
- Both dates and `calendar.holidays` are local dates; `calendar.timeZone` is not read. A caller holding an instant reduces it to a local date first, with `floorToZone`.
- Returns `null` when either date is not a valid ISO PlainDate, or `calendar` is not a valid `BusinessCalendar`. Narrow it with `isValidBusinessCalendar` to tell a misconfigured calendar apart from a genuine 0.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `start` | `string` | ISO PlainDate string, excluded from the count |
| `end` | `string` | ISO PlainDate string, included in the count |
| `calendar` | `BusinessCalendar` | BusinessCalendar naming the weekend days and holidays |

## Returns

number of working days in `(start, end]`, negative when `end` precedes `start`, or null on invalid input

## Related types

- [`BusinessCalendar`](/gmt/reference/types/BusinessCalendar/)

## Examples

```ts
import { businessDaysBetween } from "@northguild/gmt/calendar/business";

businessDaysBetween("2024-07-01", "2024-07-05", { weekend: [6, 7], holidays: ["2024-07-04"], timeZone: "Africa/Kigali" }) // 3 — Tue, Wed, Fri
```

## Source

[calendar/business/businessDaysBetween.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/calendar/business/businessDaysBetween.ts)
