> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EXTRACT

> Extracts an applicable calendar or clock component from a temporal value.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL temporal input yields NULL. Unsupported unit/type combinations can raise errors.

## Syntax

### Calendar (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
EXTRACT(unit FROM value)
```

* The unit must apply to the input type. Use one of the calendar or clock units listed above.

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| unit | SQL time-unit keyword | Yes | Calendar or clock component to extract. YEAR, MONTH, DAY, WEEK, QUARTER, HOUR, MINUTE or SECOND when applicable to the input type. Must be a constant argument. |
| value | DATE, TIME or TIMESTAMP | Yes | Temporal input. |

## Returns

* Type: INTEGER
* NULL behavior: NULL temporal input yields NULL. Unsupported unit/type combinations can raise errors.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Partial (Whole SECOND extraction excludes the fractional part of a second.) |

## Usage notes

* EXTRACT uses a unit keyword and FROM: `EXTRACT(unit FROM value)`. DATE\_PART and DATEPART use a STRING field and comma-separated arguments. Their reported return types can differ.
* With native execution, EXTRACT returns INTEGER. Java execution reports BIGINT and is outside this page’s scope.
* YEAR and MONTH can handle some out-of-range UTC or timezone-free dates that other fields cannot. Other components remain limited to their supported calendar range.

## Examples

### Extract a year

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT EXTRACT(YEAR FROM DATE '2024-01-01') AS "value";
```

| value |
| - |
| 2024 |

### Extract time fields

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT EXTRACT(HOUR FROM TIMESTAMP '2024-03-15 10:30:45') AS hour, EXTRACT(MINUTE FROM TIMESTAMP '2024-03-15 10:30:45') AS minute;
```

| hour | minute |
| - | - |
| 10 | 30 |

## Limitations

* Use the listed units. DECADE, CENTURY, and MILLENNIUM are outside this page’s supported forms.
* EPOCH, DOW, and ISODOW have different numbering or return-type rules and are outside this form.
* The parser accepts additional time-frame names and units; this form does not imply support for every such name.

## Related functions

* [date\_part](/query/sql/functions/date-time/date_part)
* [days](/query/sql/functions/date-time/days)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.