# intervalLengthDateTime

Industry: Core

## Signature

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

Return the exact length of a datetime interval in `unit`, as a real (possibly fractional) number.

- Distinct from `intervalCountDateTime`, which counts calendar/clock `unit` boundaries *crossed* rather than measuring exact duration — an interval from 23:59 to 00:01 touches 2 day boundaries via `intervalCountDateTime` but has an exact length of ~0.0014 days via `intervalLengthDateTime`.
- Uses `Temporal.Duration.prototype.total`, which resolves calendar units (month, year) against the interval's own start so a partial month is expressed as a true fraction rather than truncated.
- Returns `0` for a zero-length interval (`start === end`).
- 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

exact length of the interval expressed in `unit`, or null on invalid input

## Examples

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

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

## Source

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