# EXTRACT

> 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: EXTRACT
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-functions/timestamp-functions/extract
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/timestamp-functions/extract.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/timestamp-functions/extract.adoc
description: The `EXTRACT` function retrieves a specified part (field) from a given date/time or interval value.
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-functions/timestamp-functions/extract.md -->

The `EXTRACT` function retrieves a specified part (field) from a given date/time or interval value. It is commonly used to obtain components such as year, month, day, and hour from timestamps or dates.

## [](#syntax)Syntax

```sql
EXTRACT (field FROM source)
```

## [](#parameters)Parameters

-   `field`: String or identifier specifying the part of the date / time to extract.

-   `source`: Date / time value from which to extract the specified field.


This table shows the supported input and corresponding return types for the `EXTRACT` function:

| Input Type: source | Supported field values | Return Type |
| --- | --- | --- |
| timestamp | YEAR, MONTH, DAY, HOUR, MINUTE, SECOND | double precision |
| timestamptz | YEAR, MONTH, DAY, HOUR, MINUTE, SECOND | double precision |
| date | YEAR, MONTH, DAY | integer |

> 📝 **NOTE**
>
> The SECOND field returns a fractional value as `double precision` to include fractional seconds, not an integer type

## [](#examples)Examples

### [](#extract-with-timestamp-year)`EXTRACT` with timestamp - year

This example shows how to use the `EXTRACT` function to extract a given timestamp’s year:

```sql
SELECT EXTRACT(YEAR FROM TIMESTAMP '2025-12-31 13:30:15.123456');
```

The query returns:

```sql
+----------+
| extract  |
+----------+
| 2025     |
+----------+
```

### [](#extract-with-timestamp-month)`EXTRACT` with timestamp - month

This example uses the `EXTRACT` function to extract a given timestamp’s month:

```sql
SELECT EXTRACT(MONTH FROM TIMESTAMP '2025-12-31 13:30:15.123456');
```

The query returns the month’s part of the given timestamp:

```sql
+----------+
| extract  |
+----------+
| 12       |
+----------+
```

### [](#extract-with-timestamp-seconds-including-fractional-seconds)`EXTRACT` with timestamp - seconds (including fractional seconds)

This example uses the `EXTRACT` function to extract a given timestamp’s seconds, including fractional seconds:

```sql
SELECT EXTRACT(SECOND FROM TIMESTAMP '2025-12-31 13:30:15.123456');
```

The query returns the seconds' part of the given timestamp:

```sql
+----------+
| extract  |
+----------+
| 15.123456|
+----------+
```