Solved

Convert Date of Birth attribute to an Age attribute

  • 7 February 2023
  • 2 replies
  • 22 views

Badge +1

In the attribute manager, I would like to create a new field called ('Age') and calculate the attribute value from another field called 'Date of Birth'. This is within an automated process that will be run multiple times a month, so I need it to take the time that the process is run and use that for the age calculation. How can I do this?

This is my attempt at this : (GETDATE() - @Value(Date of Birth)) / 365 (although there is no GETDATE function as far as i'm aware of.)

 

Thanks in advance!

icon

Best answer by debbiatsafe 7 February 2023, 03:30

View original

2 replies

Userlevel 3
Badge +17

@vladimirb777​ 

The FME function for the current date and time is @DateTimeNow() as mentioned here in the Date Time documentation. To calculate the age, you can use the DateTimeCalculator transformer. Set the Start Datetime parameter to the birthday attribute and the End Datetime as @DateTimeNow() function.

If the date in the 'Date of Birth' attribute is not already in the FME datetime or ISO format, you may need to convert it first to either FME format or ISO format with the DateTimeConverter in order for the DateTimeCalculator to work.

I hope this information helps.

Badge +1

@vladimirb777​ 

The FME function for the current date and time is @DateTimeNow() as mentioned here in the Date Time documentation. To calculate the age, you can use the DateTimeCalculator transformer. Set the Start Datetime parameter to the birthday attribute and the End Datetime as @DateTimeNow() function.

If the date in the 'Date of Birth' attribute is not already in the FME datetime or ISO format, you may need to convert it first to either FME format or ISO format with the DateTimeConverter in order for the DateTimeCalculator to work.

I hope this information helps.

That worked! Thank you :)

Reply