Page 1 of 1

Age calculation from Date Of Birth

Posted: Wed Jul 02, 2008 3:47 am
by LavanyaRamesh007
I have input in which the Date of birth of customer is given. I need to find the respective age and populate that in my target. How do I achieve this..

Age= Current Date- Year of birth.. How do i go about. is there any inbuilt function for this. Kindly help :(

Re: Age calculation from Date Of Birth

Posted: Wed Jul 02, 2008 4:36 am
by Govindarajan
Use TAG.TO.YEAR for date of birth and current date and subtract these values will get you the Age of the customer.

Posted: Wed Jul 02, 2008 4:41 am
by ArndW
What format and datatype is "Date of Birth"? And is "age" an integer number of years?

Posted: Wed Jul 02, 2008 5:38 am
by LavanyaRamesh007
ArndW wrote:What format and datatype is "Date of Birth"? And is "age" an integer number of years? ...

Date of Birth is String and Age is years

Posted: Wed Jul 02, 2008 6:15 am
by ArndW
The simplest way is to extract the YYYY portion from the birthdate string and subtract it from the numeric YYYY current year value. But is this acceptable according to your business rules? Does the current month/day make a difference?

Posted: Wed Jul 02, 2008 4:21 pm
by ray.wurlod
Yes, you really do need a tighter definition. For example Chinese practice is that a newborn has an age of 1. Do you need to incorporate this possibility in your business rules?

The algorithm begins as ArndW suggests, then tests whether the day and month of birth has already occurred in the current year (in which case add 1).

Posted: Fri Jul 04, 2008 3:37 am
by LavanyaRamesh007
I had used YEARFROMDATE(SYSDATE-DATEOFBIRTH) gives the desired output..
Thanks a lot guys