Calculated age field in AEP | Community
Skip to main content
bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 28, 2025
Solved

Calculated age field in AEP

  • April 28, 2025
  • 2 replies
  • 1149 views

Hi all,

just wondering whether it is possible to calculate a dynamic field like the Profile user's age based on his birthday and keeping the value up to date e.g., on a batch update?

In other words, a field that is either preprocessed by a job or evaluated on the fly when queried.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jayakrishnaaparthasarathy

Hi @bjoern__koth  - Please find the below adobe documentation for the query schedule. We can use any functionality that can simplify our query to calculate the age based on the DOB field, make sure to create new profile enabled dataset which can be updated every week. Below is the high level syntax that can work to calculate the age but make sure to check and take it forward.

CREATE TABLE new_profile_dataset_agecalculation AS
SELECT
  date_of_birth as DOB,
  FLOOR(DATEDIFF(CURRENT_DATE, DOB) / 365.25) AS age
FROM
  current_profile_datasetname

Thank you,
Jayakrishnaa P.

2 replies

jayakrishnaaparthasarathy
Community Advisor
Community Advisor
April 28, 2025

Hi @bjoern__koth  - The below thread has an enough conversation to understand on the age calculation, please have a look. 

My own suggestion is to calculate before it is coming in to the platform, the more you utilize the mapping functionality then the more latency may occur. Also, as suggested having query service option seems to be a perfect one for a weekly job that can update your profiles. Also, do not forget to check it on computed attributes!

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform/is-it-possible-to-calculate-age-from-date-of-birth-using-data/m-p/586702

Thank you,
Jayakrishnaa P.

bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 29, 2025

thanks, @jayakrishnaaparthasarathy!

correct me if I am wrong, but aren't computed attributes only working on experience event data, and not on Profile attributes?

By any chance, have you had your hands on the query service or have some good tutorial on how this could be done through a weekly job?

Cheers from Switzerland!
jayakrishnaaparthasarathy
Community Advisor
jayakrishnaaparthasarathyCommunity AdvisorAccepted solution
Community Advisor
April 29, 2025

Hi @bjoern__koth  - Please find the below adobe documentation for the query schedule. We can use any functionality that can simplify our query to calculate the age based on the DOB field, make sure to create new profile enabled dataset which can be updated every week. Below is the high level syntax that can work to calculate the age but make sure to check and take it forward.

CREATE TABLE new_profile_dataset_agecalculation AS
SELECT
  date_of_birth as DOB,
  FLOOR(DATEDIFF(CURRENT_DATE, DOB) / 365.25) AS age
FROM
  current_profile_datasetname

Thank you,
Jayakrishnaa P.

RiteshY18
Community Advisor
Community Advisor
April 29, 2025

@bjoern__koth  may think of using 

The dateDiff function is used to retrieve the difference between two dates in the number of days.

Syntax

{%= dateDiff(datetime,datetime) %

have something like below for expression 

DateDiff(Years, profile.personalDetails.dateOfBirth, Now())

bjoern__koth
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 30, 2025

Hi @riteshy18 

cannot really see that function in the data prep list

 

Cheers from Switzerland!