Date Different in Email Template | Community
Skip to main content
Level 3
February 12, 2024
Solved

Date Different in Email Template

  • February 12, 2024
  • 3 replies
  • 1423 views

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.
Best answer by SatheeskannaK

@trojan_horse Example function with dates,

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

3 replies

SatheeskannaK
Community Advisor
Community Advisor
February 12, 2024

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

Thanks, Sathees
Level 3
February 12, 2024

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?

SatheeskannaK
Community Advisor
SatheeskannaKCommunity AdvisorAccepted solution
Community Advisor
February 12, 2024

@trojan_horse Example function with dates,

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

Thanks, Sathees
Mohan_Dugganab
Adobe Employee
Adobe Employee
February 13, 2024

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