Or if you want this...
Code:SQL*Plus: Release 9.2.0.3.0 - Production on Wed Jul 30 21:45:18 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Enter user-name: appdev@nick920 Enter password: Connected to: Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options JServer Release 9.2.0.3.0 - Production [email protected]> create table t 2 (name varchar2(30), 3 dob date) 4 / Table created. [email protected]> insert into t 2 values('nick','10-06-2001') 3 / values('nick','10-06-2001') * ERROR at line 2: ORA-01843: not a valid month [email protected]> insert into t 2 values('nick','10-jun-01') 3 / 1 row created. [email protected]> select months_between(sysdate,dob) 2 from t 3 where name like 'ni%' 4 / MONTHS_BETWEEN(SYSDATE,DOB) --------------------------- 25.674471 [email protected]> /* or if you want in days, etc...*/ [email protected]> [email protected]> select trunc(months_between(sysdate,dob)/12) years, 2 mod(trunc(months_between(sysdate,dob)),12) months, 3 sysdate - add_months(dob,trunc(months_between(sysdate,dob))) days 4 from t 5 where name like 'ni%' 6 / YEARS MONTHS DAYS ---------- ---------- ---------- 2 1 20.9149537 [email protected]>





Reply With Quote