Expand my Community achievements bar.

Adobe Journey Optimizer Community Lens 6th edition is out.
SOLVED

Date Different in Email Template

Avatar

Level 2

I have a bit of an urgent ask so any quick responses would be appreciated.

 

I want to find the difference between the current date and another date in the email template and render content based on the value of the difference (i.e. let's say the date today is 02/12/2024 and the date attribute of another field is 02/08/2024. I'd then like to find the difference between these two dates which will be 4 and render content based on that) 

 

I know this can be done within the AJO conditions but how can I do this within the emails?

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@trojan_horse Example function with dates,

{%#if profile.person.birthDate.getDayOfYear() - now.getDayOfYear() = 4 %}
test1
{%else%}
test2
{%/if%}

Thanks, Sathees

View solution in original post

4 Replies

Avatar

Level 2

I've tried but that only seems to take dateTime values and I just have the dates. Could you give an example of how this can be used with just the dates?

Avatar

Correct answer by
Community Advisor

@trojan_horse Example function with dates,

{%#if profile.person.birthDate.getDayOfYear() - now.getDayOfYear() = 4 %}
test1
{%else%}
test2
{%/if%}

Thanks, Sathees

Avatar

Employee

Following expression can be leveraged to find the difference between date fields

 

{% let currentDate = now %}
{% let currentDayOfYear = dayOfYear(currentDate) %}

{%#if currentDayOfYear - dayOfYear(<another date field>) = 4 %}
element_1
{%else%}
default_element
{%/if%}