Skip to main content
Solved

Convert Date of Birth attribute to an Age attribute

  • February 7, 2023
  • 2 replies
  • 128 views

Forum|alt.badge.img+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!

Best answer by debbiatsafe

@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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • Best Answer
  • February 7, 2023

@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.


Forum|alt.badge.img+1
  • Author
  • 2 replies
  • February 7, 2023

@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 :)