Definition:
In Oracle PL/SQL, YEAR is a datetime field which specifies the year contained by a date value in either a numeric or string format. It is valid for both DATETIME and INTERVAL data type values. The valid value range for YEAR in datetime values is -4712 to 9999 (excluding year 0). For INTERVAL type values, valid range of year precision is 0 to 9. It can be extracted using the EXTRACT function from a DATETIME value.
Example Usage:
The SQL below extracts the month from the current date.
SQL> SELECT EXTRACT(YEAR FROM SYSDATE) FROM DUAL;
EXTRACT(YEARFROMSYSDATE)
------------------------
2011
The SQL below extracts the month from the INTERVAL period.
SQL> SELECT INTERVAL '1' YEAR (9) FROM DUAL
INTERVAL'1'YEAR(9)
---------------------------------------------------------------------
+000000001-00
SQL> SELECT INTERVAL '1-2' YEAR (3) TO MONTH FROM DUAL
INTERVAL'1-2'YEAR(3)TOMONTH
---------------------------------------------------------------------------
+001-02
Related Links:
Related Code Snippets: