EXTRACT
functionsupportedCore SQL functionsExtracts the specified date or time part from a date, interval, time, or timestamp. Tip To extract the date from a timestamp, use the TO_DATE function.
Syntax
EXTRACT( <date_or_time_part> FROM <date_interval_time_or_timestamp_expr> )
EXTRACT( <date_or_time_part> , <date_interval_time_or_timestamp_expr> )
Parameters
| Name | Required | Description |
|---|---|---|
date_or_time_part | required | The unit of time. Must be one of the values listed in Supported date and time parts (for example, month). The value can be a string literal or can be unquoted (for example, 'month' or month). When date_or_time_part is week (or any of its variations), the output is controlled by the WEEK_START session parameter. When date_or_time_part is dayofweek or yearofweek (or any of their variations), the output is controlled by the WEEK_OF_YEAR_POLICY and WEEK_START session parameters. For more information, including examples, see Calendar weeks and weekdays. |
date_interval_time_or_timestamp_expr | required | A date, an interval, a time, or a timestamp, or an expression that can be evaluated to one of those data types. |
Returns
Returns a value of NUMBER data type.
Usage notes
- When date_interval_time_or_timestamp_expr is a year-month interval value, the supported date_or_time_part values are year and month.
- When date_interval_time_or_timestamp_expr is a day-time interval value, the supported date_or_time_part values are day, hour, minute, second, and nanosecond.
- Currently, when date_interval_time_or_timestamp_expr is a DATE value, the following date_or_time_part values aren’t supported: epoch_millisecond
- epoch_microsecond
- epoch_nanosecond
- Other date and time parts (including epoch_second) are supported.