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

# compareDatePeriodLiterals()

- 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).
> 

Compares two valid period literals of the same granularity.

**Signature:**

```typescript
export declare function compareDatePeriodLiterals(granularity: DatePeriodGranularity | DateRangeParameterGranularity, a: DatePeriodLiteral, b: DatePeriodLiteral): number;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| granularity | [DatePeriodGranularity](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodgranularity/index.md) \| [DateRangeParameterGranularity](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.daterangeparametergranularity/index.md) |  |
| a | [DatePeriodLiteral](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodliteral/index.md) |  |
| b | [DatePeriodLiteral](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.dateperiodliteral/index.md) |  |

**Returns:**

number

a negative number when 'a' is earlier than 'b', zero when they are the same period and a positive  number when 'a' is later than 'b'
