# mapDatesInRange

Industry: Core

## Signature

```ts
mapDatesInRange(startDate: string, endDate: string, stepDays?: number, options?: { maxPieces?: number; }): string[]
```

Return an array of ISO PlainDate strings between `startDate` and `endDate` inclusive.

- Generates dates with optional step (default 1 day).
- Returns [] if start &gt; end, invalid inputs, or step &lt;= 0.
- An explicit `undefined` `stepDays` is the default step, so `(start, end, undefined, options)` reaches `options`. **Compatibility:** before 1.16.0 it returned `[]`.
- **End-inclusive, where the `interval*` functions are half-open.** This enumerates the dates a range covers, so `endDate` is one of them; an interval bounds a span as `[start, end)`, so its `end` is not. The same pair therefore yields one more date here than `intervalCountDate` counts. To read one set of bounds both ways, pass `addDate(endDate, { days: 1 })` to the `interval*` call, or `subtractDate(endDate, { days: 1 })` to this one.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `startDate` | `string` | ISO PlainDate string for the first date |
| `endDate` | `string` | ISO PlainDate string for the last date (inclusive) |
| `stepDays` | `number` | optional number of days to step between results |

## Options

**options**

The limit on the size of the result

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `maxPieces?` | `number` | `1_000_000` | The most dates the result may hold. A result that would hold more, or more than the longest possible array (2^32 - 1 elements), returns `[]` and none is built. A value that is not a positive safe integer also returns `[]`. |

## Returns

array of ISO PlainDate strings, or [] on invalid input

## Examples

```ts
import { mapDatesInRange } from "@northguild/gmt/plain/map";

mapDatesInRange("2024-03-01", "2024-03-05") // ["2024-03-01", "2024-03-02", "2024-03-03", "2024-03-04", "2024-03-05"]
```

## Source

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