0

I am using IBM DataStage Below is transformer stage expression, where I have date from Link_4.DOB with format of %yyyy%mm%dd (20231221). I want to calculate the age:

Below is my simple try, but it's not an accurate DOB

YearFromDate(CurrentDate()) - YearFromDate(StringToDate(Link_4.DOB, "%yyyy%mm%dd"))

Is it possible to calculate the exact age based on the expression supported by DataStage?

william007
  • 17,375
  • 25
  • 118
  • 194

1 Answers1

0

Use your approach (your_result) and add a logic to compare month and days additionally.

Pseudo code

IF YearFromDate(CurrentDate()) : Link_4.DOB[5,4] < CurrentDate() 
THEN your_result - 1
ELSE your_result

This will build this years birthdays and compare it to the current date. If the current date is smaller than this years birthday your year-logic will be corrected by -1.

MichaelTiefenbacher
  • 3,805
  • 2
  • 11
  • 17