Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL YEAR Keyword      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: YEAR

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:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 53 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?