EXTRACT( )
Go Up to Statement and Function Reference (Language Reference Guide)
Extracts date and time information from DATE, TIME, and TIMESTAMP values. Available in gpre, DSQL, and isql.
EXTRACT (part FROM value)
| Argument | Description |
|---|---|
|
<part> |
|
|
<value> |
|
Description: The value passed to the EXTRACT() expression must be a DATE, a TIME, or a TIMESTAMP. Extracting a part that does not exist in a data type results in an error. For example, a statement such as tEXTRACT (YEAR from aTime) would fail.
- Note: The data type of part depends on which part is extracted.
| Part extracted | Datatype | Range |
|---|---|---|
|
|
|
0–5400 |
|
|
|
1–12 |
|
|
|
1–31 |
|
|
|
0–23 |
|
|
|
0–59 |
|
|
|
0–59.9999 |
|
|
|
0–6 (0 = Sunday, 1 = Monday, etc.) |
|
|
|
0–365 |
Example: EXTRACT(HOUR FROM StartTime);