If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Calculating age in Oracle

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-22-04, 00:26
ashazi ashazi is offline
Registered User
 
Join Date: May 2004
Posts: 4
Question 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
Reply With Quote
  #2 (permalink)  
Old 05-22-04, 05:15
SkyWriter SkyWriter is offline
Registered User
 
Join Date: Jan 2004
Posts: 370
select pid, trunc((months_between(sysdate, dob))/12) age
from customers;
Reply With Quote
  #3 (permalink)  
Old 05-23-04, 01:58
ashazi ashazi is offline
Registered User
 
Join Date: May 2004
Posts: 4
Hi Sky,
Thanks! That does help.



ashazi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On