EXTRACT (datetime)

EXTRACT returns the value of a specified field from a datetime or interval expression.

Return Value

NUMBER

Syntax

EXTRACT( { { YEAR
           | MONTH
           | DAY
           | HOUR
           | MINUTE
           | SECOND
           }
         | { TIMEZONE_HOUR
           | TIMEZONE_MINUTE
           }
         | { TIMEZONE_REGION
           | TIMEZONE_ABBR
           }
         }
    FROM   { datetime_value_expression
           | interval_value_expression
           }
       )

Arguments

datetime_value_expression is an expression with a datetime data type.

interval_value_expression is an expression with an interval data type.

Example

EXTRACT(MONTH FROM CURRENT_TIMESTAMP) returns the value 8 for August when the current timestamp is 08-AUG-06 01.10.55.330120 PM -07:00.

EXTRACT(TIMEZONE_HOUR FROM CURRENT_TIMESTAMP) returns the value -7 from the same example.