Return to Snippet

Revision: 71317
at February 18, 2017 09:11 by bbrumm


Initial Code
--Example 1
SELECT SYSDATE, 
EXTRACT(YEAR FROM SYSDATE) as EXTRACT_EXAMPLE
FROM dual;

--Example 2
SELECT SYSDATE, 
EXTRACT(MONTH FROM SYSDATE) as EXTRACT_EXAMPLE
FROM dual;

--Example 3
SELECT SYSDATE, 
EXTRACT(DAY FROM SYSDATE) as EXTRACT_EXAMPLE
FROM dual;

--Example 4
SELECT SYSDATE, 
EXTRACT(HOUR FROM SYSDATE) as EXTRACT_HOUR
FROM dual;

--Example 5
SELECT SYSTIMESTAMP, 
EXTRACT(HOUR FROM SYSTIMESTAMP) as EXTRACT_HOUR,
EXTRACT(MINUTE FROM SYSTIMESTAMP) as EXTRACT_MINUTE,
EXTRACT(SECOND FROM SYSTIMESTAMP) as EXTRACT_SECOND
FROM dual;

--Example 6
SELECT SYSTIMESTAMP, 
EXTRACT(TIMEZONE_HOUR FROM SYSTIMESTAMP) as EXTRACT_TIMEZONE_HOUR,
EXTRACT(TIMEZONE_MINUTE FROM SYSTIMESTAMP) as EXTRACT_TIMEZONE_MINUTE,
EXTRACT(TIMEZONE_REGION FROM SYSTIMESTAMP) as EXTRACT_TIMEZONE_REGION,
EXTRACT(TIMEZONE_ABBR FROM SYSTIMESTAMP) as EXTRACT_TIMEZONE_ABBR
FROM dual;

--Example 7
SELECT TO_YMINTERVAL('03-02'),
EXTRACT(YEAR FROM TO_YMINTERVAL('03-02')) as EXTRACT_YEAR,
EXTRACT(MONTH FROM TO_YMINTERVAL('03-02')) as EXTRACT_MONTH
FROM dual;

Initial URL
http://www.databasestar.com/oracle-extract/

Initial Description
A few examples of the EXTRACT function.

Initial Title
Oracle EXTRACT Function

Initial Tags
sql, Oracle

Initial Language
SQL