Coco Beans
asked on
Calculating Date of Birth
I have a table with Register_ Year, Date of Birth. I need to calculate Age using 01-10-Register_ Year and Date of Birth. Can anyone help with this in Oracle
What are the data types of your two columns: Register_ Year and Date of Birth?
If "Date of Birth" is already a "date" column, it seems that you would not need to calculate a date of birth. But, if that column is actually a VARCHAR2, CHAR or NUMBER column that contains a month and day, then doing this calculation becomes more complex. The biggest challenge then is likely to be "dirty data", that is: values that don't fit a consistent pattern, or are incomplete, or have invalid values, like "Feb. 30" or "13" for a numeric month.
If "Date of Birth" is already a "date" column, it seems that you would not need to calculate a date of birth. But, if that column is actually a VARCHAR2, CHAR or NUMBER column that contains a month and day, then doing this calculation becomes more complex. The biggest challenge then is likely to be "dirty data", that is: values that don't fit a consistent pattern, or are incomplete, or have invalid values, like "Feb. 30" or "13" for a numeric month.
If "Date of Birth" is already a "date" column, it seems that you would not need to calculate a date of birth.
the title was wrong. the right question is
How to calculate the age from 'register year' and 'date of birth'.
as told in the body of the question.
my problem is that i don't know what
1-10 register_yearis? is it a 4-digit year (string) as assumed by slightwv? or is it the indices 1,2,..10 pointing to a table of register years?
Coco, can you give better information?
Sara
ASKER
Calculated like this..
TRUNC((TO_NUMBER(REGISTER_ YEAR||'010 1')-TO_NUM BER(TO_CHA R( BIRTH_DATE ,'yyyymmdd')))/10000)
TRUNC((TO_NUMBER(REGISTER_
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>you better should try straight-forward
That would be great if YEAR was an Oracle function:
to_number(to_char(birth_da te,'yyyy') )
or
extract(year from birth_date)
That would be great if YEAR was an Oracle function:
to_number(to_char(birth_da
or
extract(year from birth_date)
It might not be exact but you get the idea.