3 Replies Latest reply on Dec 19, 2013 8:29 AM by Hoek

# Calculate age in oracle 11g

how do i calculate age based on date picker in another field on the same table/

• ###### 1. Re: Calculate age in oracle 11g

You can find your age by executing given below query.

SELECT Round((sysdate-Date_of_birth)/365) from dual;

Example:-

If Your Date of birth is

SELECT Round((SYSDATE-'01-JAN-1989')/365) FROM DUAL;

• ###### 2. Re: Calculate age in oracle 11g

Are you sure of that algorithm?

orclz> SELECT Round((SYSDATE-to_date('01-JAN-1989','dd-MON-yyyy'))/365) FROM DUAL;

ROUND((SYSDATE-TO_DATE('01-JAN-1989','DD-MON-YYYY'))/365)

---------------------------------------------------------

25

orclz> SELECT Round((SYSDATE-to_date('01-DEC-1989','dd-MON-yyyy'))/365) FROM DUAL;

ROUND((SYSDATE-TO_DATE('01-DEC-1989','DD-MON-YYYY'))/365)

---------------------------------------------------------

24

orclz> select extract (year from sysdate) - extract( year from to_date('01-DEC-1989','dd-MON-yyyy')) from dual;

EXTRACT(YEARFROMSYSDATE)-EXTRACT(YEARFROMTO_DATE('01-DEC-1989','DD-MON-YYYY'))

------------------------------------------------------------------------------

24

orclz> select extract (year from sysdate) - extract( year from to_date('01-JAN-1989','dd-MON-yyyy')) from dual;

EXTRACT(YEARFROMSYSDATE)-EXTRACT(YEARFROMTO_DATE('01-JAN-1989','DD-MON-YYYY'))

------------------------------------------------------------------------------

24

orclz>