Firebird Documentation Index → Firebird 1.5 Language Ref. Update → Internal functions → EXTRACT() |
Find a more recent version at Firebird 5.0 Language Reference: EXTRACT()
Available in: DSQL, ESQL, PSQL
Added in: IB 6
Description: Extracts and returns an element from a DATE, TIME or TIMESTAMP expression. It was already added in InterBase 6, but not documented in the Language Reference at the time.
Return type: SMALLINT or DECIMAL(6,4)
Syntax:
EXTRACT (<part>
FROM<datetime>
)<part>
::= YEAR | MONTH | DAY | WEEKDAY | YEARDAY | HOUR | MINUTE | SECOND<datetime>
::= An expression of type DATE, TIME or TIMESTAMP
The returned datatype is DECIMAL(6,4) for the SECOND part and SMALLINT for all others. The ranges are shown in the table below.
If you try to extract a part that isn't present in the date/time argument (e.g. SECOND from a DATE or YEAR from a TIME), an error occurs.
Table 10.1. Ranges for EXTRACT results
Part | Range | Comment |
---|---|---|
YEAR | 1–9999 | |
MONTH | 1–12 | |
DAY | 1–31 | |
WEEKDAY | 0–6 | 0 = Sunday |
YEARDAY | 0–365 | 0 = January 1 |
HOUR | 0–23 | |
MINUTE | 0–59 | |
SECOND | 0.0000–59.999 |
Firebird Documentation Index → Firebird 1.5 Language Ref. Update → Internal functions → EXTRACT() |