Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.
SOLVED

Customers who turn 18

Avatar

Level 2

Hi, I need to identify customers who turn 18 today from the birth date with an fx. How can I do it?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@PietroAm1 Unfortunately, there isn't a function available to determine the age; instead, you'll need to utilize an expression similar to what Mohan mentioned. Another option would be to use a computed attribute.

Thanks, Sathees

View solution in original post

7 Replies

Avatar

Community Advisor

@PietroAm1 Use the computed attributes to calculate the age and use that field in the audience definition.

https://experienceleague.adobe.com/en/docs/experience-platform/profile/computed-attributes/overview

Thanks, Sathees

Avatar

Level 2

Pretty strange but we do not have this (and other functions) in AJO, that's why I've asked. I attach screenshot

Cattura.PNG

Avatar

Correct answer by
Community Advisor

@PietroAm1 Unfortunately, there isn't a function available to determine the age; instead, you'll need to utilize an expression similar to what Mohan mentioned. Another option would be to use a computed attribute.

Thanks, Sathees

Avatar

Employee Advisor

Avatar

Employee Advisor

@PietroAm1 Adobe Journey Optimizer provides Date functions, which you can use to manipulate and compare dates in your expressions, such as addYears, formatDate, and logical comparison operators.
here is what you can try: 

if your birth date field is profile.person.birthDate, the expression in the audience rule or decision block would look like:


{{formatDate addYears profile.person.birthDate 18 "yyyy-MM-dd"}} == {{formatDate now "yyyy-MM-dd"}}

This logic checks if today's date (formatted as yyyy-MM-dd) matches the birth date plus 18 years (also formatted as yyyy-MM-dd). You may want to adapt the field name based on your profile schema.

 

Avatar

Level 2

Thnaks, just tried with expression below, swapping my schema's field

 

{{formatDate addYears #{ExperiencePlatform.ProfileFieldGroup.profile._cagroupit.anagraficaCliente.DATA_NASCITA} 18 "YYYY-MM-DD"}} == {{formatDate now "yyyy-MM-dd"}}

 

it returns error

 

The expression is invalid : Unexpected character '{' . Please, check that it is a valid token and that you are using it at the right place.

 

Avatar

Employee Advisor

@PietroAm1  try

let dob          = #{ExperiencePlatform.ProfileFieldGroup.profile._cagroupit.anagraficaCliente.DATA_NASCITA};
let eighteenth   = date(getYear(dob)+18 ,   /* year  */
                       getMonth(dob)  ,   /* month */
                       getDayOfMonth(dob) /* day   */);

/* Compare to today */
(eighteenth == toDateOnly(now()))