# interval

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: interval
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-data-types/interval
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-data-types/interval.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-data-types/interval.adoc
description: The Interval data type represents periods between dates or times, which can be precisely calculated and expressed through various units.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/interval.md -->

The Interval data type represents periods between dates or times, which can be precisely calculated and expressed through various units. Those can be combined and include additional options for different interval calculations.

## [](#syntax)Syntax

The syntax for specifying an interval is as follows:

```sql
SELECT INTERVAL 'quantity unit [quantity unit...] [direction]' [OPTION]
```

| Parameter | Description |
| --- | --- |
| quantity | The value representing the number of units. |
| unit | Year, month, day, hour, and minute. Abbreviations, short forms, and dash format are supported. Plural forms are also acceptable (for example, months, days, weeks). |
| direction | An optional parameter: ago or empty string. |
| OPTION | Additional options when parsing interval. |

> 📝 **NOTE**
>
> For arithmetic and comparison operations, Redpanda SQL assumes `1 month = 30 days` and `1 day = 24 hours`. However, adding 30 days to a timestamp is not always equivalent to adding 1 month, because calendar months have different durations.

## [](#supported-units-and-abbreviations)Supported units and abbreviations

| Unit | Abbreviations |
| --- | --- |
| Millennium | - |
| Century | - |
| Decade | - |
| Year | y, yr, yrs |
| Month | - |
| Week | - |
| Day | d |
| Hour | h, hr, hrs |
| Minute | min, mins, m |
| Second | s, sec, secs |
| Millisecond | ms |
| Microsecond | - |

## [](#options-for-interval-parsing)Options for interval parsing

-   `YEAR`, `MONTH`, `DAY`, `HOUR`, `MINUTE`, `SECOND`

-   `YEAR TO MONTH`, `DAY TO HOUR`, `DAY TO MINUTE`, `DAY TO SECOND`, `HOUR TO MINUTE`, `HOUR TO SECOND`, `MINUTE TO SECOND`


## [](#examples)Examples

### [](#select-interval-with-multiple-units)Select interval with multiple units

This example calculates an interval by combining multiple units of time.

```sql
SELECT INTERVAL '5 years 4 months 2 weeks 3 days 5 hours 10 minutes 25 seconds' as "Interval";
```

```sql
            Interval
---------------------------------
 5 years 4 mons 17 days 05:10:25
(1 row)
```

### [](#use-abbreviations)Use abbreviations

This example shows how to use abbreviated units for time intervals.

```sql
SELECT INTERVAL '10 yr 8 months 2 weeks 6 days 5 hrs 10 min 20 s' as "Interval";
```

```sql
             Interval
----------------------------------
 10 years 8 mons 20 days 05:10:20
(1 row)
```

### [](#use-dash-format)Use dash format

```sql
SELECT INTERVAL '1-2 3 DAYS 04:05:06.070809' as "Interval";
```

```sql
               Interval
--------------------------------------
 1 year 2 mons 3 days 04:05:06.070809
(1 row)
```

### [](#parse-intervals-using-specific-units)Parse intervals using specific units

By running the following code, the output shows everything up to minutes and ignores seconds and milliseconds.

```sql
SELECT INTERVAL '1-2 5 DAYS 07:08:06.040809' MINUTE as "Interval";
```

```sql
           Interval
-------------------------------
 1 year 2 mons 5 days 07:08:00
(1 row)
```

### [](#display-specific-range-only)Display specific range only

Executing the following query results in only years and months being displayed, excluding days, hours, minutes, and seconds from the input.

```sql
SELECT INTERVAL '2-4 5 DAYS 04:05:06.070809' YEAR TO MONTH as "Interval";
```

```sql
    Interval
----------------
 2 years 4 mons
(1 row)
```

### [](#extract-data-from-interval)Extract data from interval

To extract interval numbers from a timestamp, use the `EXTRACT` function:

```sql
SELECT EXTRACT (field FROM interval)
```

-   `field`: Supports time units, such as `YEAR`, `MONTH`, `DAY`, and `HOUR`.

-   `interval`: Specified timestamp.


```sql
SELECT EXTRACT (MINUTE
FROM INTERVAL '2 hours 30 minutes');
```

The output returns only the minutes part:

```sql
   extract
------------
        30
(1 row)
```

> 📝 **NOTE**
>
> If you query a field that is not specified in the timestamp, the output is `0`.