Skip to main content
Level 3
Feb 12, 2024 8:36 PM UTC
Solved

Date Different in Email Template

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SatheeskannaK
SatheeskannaKAccepted solution
Adobe Champion, Community Advisor, UG Leader
Feb 12, 2024 10:24 PM UTC

@trojan_horse Example function with dates,

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

Thanks, Sathees

4 replies

SatheeskannaK
Adobe Champion, Community Advisor, UG Leader
Adobe Champion, Community Advisor, UG Leader
Feb 12, 2024 9:29 PM UTC

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

Translate
Thanks, Sathees
Level 3
Feb 12, 2024 9:49 PM UTC

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?

Translate
SatheeskannaK
Adobe Champion, Community Advisor, UG Leader
SatheeskannaKAdobe Champion, Community Advisor, UG LeaderAccepted solution
Adobe Champion, Community Advisor, UG Leader
Feb 12, 2024 10:24 PM UTC

@trojan_horse Example function with dates,

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

Translate
Thanks, Sathees
Mohan_Dugganab
Adobe Employee
Adobe Employee
Feb 13, 2024 3:21 AM UTC

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

 

Translate