Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    4

    Question Unanswered: Calculating age in Oracle

    I'm using Oracle 8i and I've got a customers relation(table) where I need to calculate the age of the customers. I've got their dates of birth in a field called dob, and I tried using SYSDATE with the following command :

    select pid, dob(dob, sysdate)
    from customers;

    For this, I got the error message :
    ERROR at line 1:
    ORA-00904: invalid column name

    What am I doing wrong? Does anyone know how I can calculate the customers' age using SYSDATE? Can anyone help?

    Thanks!

    ashazi

  2. #2
    Join Date
    Jan 2004
    Posts
    370
    select pid, trunc((months_between(sysdate, dob))/12) age
    from customers;

  3. #3
    Join Date
    May 2004
    Posts
    4
    Hi Sky,
    Thanks! That does help.



    ashazi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •