Skip to main content

Hi,

I have birth days in this format YYYY-MM-DD.

I want to calculate their ages.

Per exemple, someone born 1950-03-28 would be 70 years old.

Not sure how to do that. Any idea?

Thanks

Convert both dates to seconds since epoch (%Es), find the difference, then convert back to years. If you don't need to take leap years into account, the easiest is to divide by 31556952 (the number of seconds in a non-leap year).


Or to be completely accurate (using leap years and all), first convert the dates to FME timestamps then use the DateTimeCalculator:


I'd probably use the Date/Time Functions, so parse the attribute named birthdate into date format, calculate the difference in years from today's date and round down

@floor(@DateTimeDiff(@DateTimeNow(),@DateTimeParse(@Value(birthdate),%Y-%m-%d),Years))

0684Q00000ArKSRQA3.png


Or to be completely accurate (using leap years and all), first convert the dates to FME timestamps then use the DateTimeCalculator:

Nice I didn't know we could do that :D

I need to put an AttributeRounder after to take out de decimals though.

Thanks!!


Reply