Thanks for the question.
Asked: April 14, 2009 - 4:20 pm UTC
Last updated: April 15, 2009 - 3:12 pm UTC
Version: 9i
Viewed 10K+ times! This question is
ops$tkyte%ORA9IR2> create table t ( x date ); Table created. ops$tkyte%ORA9IR2> insert into t values ( to_date( '15-mar-1965', 'dd-mon-yyyy' ) ); 1 row created. ops$tkyte%ORA9IR2> ops$tkyte%ORA9IR2> select ( systimestamp - cast( x as timestamp ) ) year to month from t; (SYSTIMESTAMP-CAST(XASTIMESTAMP))YEARTOMONTH --------------------------------------------------------------------------- +000000044-01 ops$tkyte%ORA9IR2> select trunc(months_between(sysdate,x)/12) years, 2 months_between(sysdate,x)-12*trunc(months_between(sysdate,x)/12) months 3 from t; YEARS MONTHS ---------- ---------- 44 1
Dave Swift, April 16, 2009 - 7:32 am UTC
anchal, June 19, 2012 - 12:38 pm UTC
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!