EXTRACT is one of the vital Date/Time functions of Oracle. It is used to extract a value from a date or interval value. The EXTRACT function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i.
Syntax:
EXTRACT ( { YEAR | MONTH | DAY | HOUR | MINUTE | SECOND } | { TIMEZONE_HOUR | TIMEZONE_MINUTE } | { TIMEZONE_REGION | TIMEZONE_ABBR } FROM { date_value | interval_value } )
Example 1:
EXTRACT (YEAR FROM DATE '2019-06-26') |
Output:
2019
Explanation:
The Extract function will extract only the year value from the given date.
Example 2:
EXTRACT (MONTH FROM DATE '2019-06-26') |
Output:
6
Explanation:
The Extract function will extract only the Month value from the given date.