How to calculate Age in informatica power center

How to calculate the Age in informatica power center. You can use the function DATE_DIFF.

We normally calculate the age by substracting the current date from Date of Birth. In my case I have date of birth is available in the source file. I have created a port in an expression transformation and calculate the age by using the function DATE_DIFF.

DATE_DIFF
Returns the length of time between two dates. You can request the format to be years, months, days, hours, minutes, seconds, milliseconds, microseconds, or nanoseconds. The PowerCenter Integration Service subtracts the second date from the first date and returns the difference. The syntax is below. The date1 & date2 should be in an actual DATE format.

DATE_DIFF(<em>date1</em>,<em>date2</em>, <em>format</em> )
Code language: HTML, XML (xml)

To Calculate the Date, use the below function in the expression. This will substract the Date Of Birth from Current-date and give the result in 2 digit year format and thats the exact age for a person. In your source if the DTE_BIRTH is a string field (01011980), make sure to convert it into actual date format before using in the DATE_DIFF function.

DATE_DIFF( SYSDATE,DTE_BIRTH, 'YY' )
Code language: JavaScript (javascript)
Expression transformation with DATE_DIFF function!

Sample output – Age is calculated from date of birth

Have any questions? or need help with this topic, please do reach out to me at kvtinformatica@gmail.com. Don’t forget to follow my Youtube channel and FB page, Lets stay connected and learn together.