Expand my Community achievements bar.

Join us for the Adobe Journey Optimizer Community Q&A Coffee Break on 28th February at 8 am PT with Ariel Sultan, Daniel Wright, Josee Haeley and Rohit Basuri.

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.

4 Replies

Avatar

Community Advisor

@trojan_horse, You can use Date Difference function given here.

Thanks, Sathees

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

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%}