# intervalCountDateTime

Industry: Core

## Signature

```ts
intervalCountDateTime(start: string, end: string, unit: string): number | null
```

Count how many `unit` boundaries a date-time interval crosses.

- Counts calendar boundaries touched by the half-open interval `[start, end)` — distinct from `diffDateTime`, which measures exact elapsed duration. An interval from 23:59 to 00:01 is two minutes long but touches 2 day boundaries.
- The end boundary is excluded: `"2024-01-01T00:00:00"` to `"2024-01-03T00:00:00"` counts 2 days.
- A zero-length interval (`start === end`) returns `0`: the empty `[start, start)` holds no instant, so it touches no unit (before 1.16.0 it counted 1 when mid-unit).
- Weeks start on Monday (ISO 8601).
- A unit that began before the first representable PlainDateTime (`-271821-04-19T00:00:00.000000001`) is still counted: whole units are measured from the unit after `start`'s, never from `start`'s own start.
- Accepts singular or plural units (`"day"` and `"days"` behave identically).
- Returns `null` on invalid input (unparseable start/end, `start > end`, unsupported unit).

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `start` | `string` | ISO PlainDateTime string for the interval start |
| `end` | `string` | ISO PlainDateTime string for the interval end |
| `unit` | `string` | unit string — any `DateTimeUnit` |

## Returns

number of unit boundaries touched, or null on invalid input

## Examples

```ts
import { intervalCountDateTime } from "@northguild/gmt/plain/interval";

intervalCountDateTime("2024-01-01T23:59:00", "2024-01-02T00:01:00", "day") // 2
```

## Source

[plain/interval/intervalCountDateTime.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/interval/intervalCountDateTime.ts)
