Expand my Community achievements bar.

Adobe Summit 2025: AEP & RTCDP Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.
SOLVED

Calculated age field in AEP

Avatar

Community Advisor

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.

Cheers from Switzerland!


Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

View solution in original post

6 Replies

Avatar

Community Advisor

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

Thank you,
Jayakrishnaa P.

Avatar

Community Advisor

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!


Avatar

Correct answer by
Community Advisor

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.

Avatar

Community Advisor

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

Avatar

Community Advisor

Hi @RiteshY18 

cannot really see that function in the data prep list

bjoern__koth_0-1746023647810.png

 

Cheers from Switzerland!


Avatar

Community Advisor