Age calculation from Date Of Birth

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
LavanyaRamesh007
Participant
Posts: 42
Joined: Mon Apr 21, 2008 1:49 am

Age calculation from Date Of Birth

Post 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 :(
Govindarajan
Participant
Posts: 24
Joined: Mon Jul 12, 2004 10:16 am

Re: Age calculation from Date Of Birth

Post 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.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What format and datatype is "Date of Birth"? And is "age" an integer number of years?
LavanyaRamesh007
Participant
Posts: 42
Joined: Mon Apr 21, 2008 1:49 am

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
LavanyaRamesh007
Participant
Posts: 42
Joined: Mon Apr 21, 2008 1:49 am

Post by LavanyaRamesh007 »

I had used YEARFROMDATE(SYSDATE-DATEOFBIRTH) gives the desired output..
Thanks a lot guys
Post Reply