EXTRACT
The EXTRACT function extracts and returns the value of a specified datetime field from a datetime or interval value expression as a NUMBER data type. This function can be useful for manipulating datetime field values in very large tables.
SQL syntax
EXTRACT (DateTimeField FROM IntervalExpression | DateTimeExpression)
Parameters
EXTRACT has the following parameters:
| Parameter | Description |
|---|---|
|
|
The field to be extracted from |
|
|
An interval result. |
|
|
A datetime expression. For example, |
Description
-
Some combinations of
DateTimeFieldandDateTimExpressionorIntervalExpressionresult in ambiguity. In these cases, TimesTen returnsUNKNOWN. -
The field you are extracting must be a field of the
IntervalExpressionorDateTimeExpression. For example, you can extract onlyYEAR,MONTH, andDAYfrom aDATEvalue. Likewise, you can extractHOUR,MINUTEorSECONDonly from theTIME,DATE, orTIMESTAMPdata type. -
The fields are extracted into a
NUMBERvalue.
Examples
The following example extracts the second field out of the interval result sysdate-t1.createtime.
SELECT EXTRACT(SECOND FROM sysdate-t1.createtime) FROM t1;
The following example extracts the second field out of sysdate from the dual system table.
Command> SELECT EXTRACT (SECOND FROM sysdate) FROM dual; < 20 > 1 row found.