Monday, July 30, 2012

Age Calculation using “Interval Year to Month” data type.


Interval year to Month oracle data type is used to store the time period in years and months. EXTRACT function is used to extract the value from the interval data types (get the years, months, seconds .... etc.,).

SQL>SELECT  EXTRACT(YEAR FROM(TRUNC(SYSDATE) - :BIRTH_DATE) YEAR TO MONTH)  AGE FROM DUAL;

No comments:

Post a Comment