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
DateTimeField
andDateTimExpression
orIntervalExpression
result in ambiguity. In these cases, TimesTen returnsUNKNOWN
. -
The field you are extracting must be a field of the
IntervalExpression
orDateTimeExpression
. For example, you can extract onlyYEAR
,MONTH
, andDAY
from aDATE
value. Likewise, you can extractHOUR
,MINUTE
orSECOND
only from theTIME
,DATE
, orTIMESTAMP
data type. -
The fields are extracted into a
NUMBER
value.
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.