> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# toDatePeriodRange()

- Package: [@gooddata/sdk-model](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/index.md)
- Kind: function
- Stability: alpha
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.71/libs/sdk-model/src/base/datePeriodLiterals.ts

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Makes the range of periods of a filter from its ends.

**Signature:**

```typescript
export declare function toDatePeriodRange(from: DatePeriodLiteral | undefined, to: DatePeriodLiteral | undefined): DatePeriodRange;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| from | [DatePeriodLiteral](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodliteral/index.md) \| undefined | first period of the range; undefined for a range open at the start |
| to | [DatePeriodLiteral](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodliteral/index.md) \| undefined | last period of the range; undefined for a range open at the end |

**Returns:**

[DatePeriodRange](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodrange/index.md)

the range

## Exceptions

Error when neither end is set

## Remarks

A range has at least one end; the one it lacks is left out, so the range is open on that side. The function does not check the literals, see [isValidDatePeriodRange()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.isvaliddateperiodrange/index.md).
