Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

dynamic date in email body

Avatar

Level 2

Hi Team,

 

We are trying to populate the dynamic offer end date in email creative base on journey run date + 30 days in specific format.

Did anyone can help me on the same? I can populate the date (2023-07-02) but want in MM/DD/YYYY format

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@ST_questions,

You can use the formatDate function to display the date format as MM/DD/YYYY.

{% let d=now %}
{%= formatDate(d, "mm/dd/YYYY") %}

Thanks, Sathees

View solution in original post

12 Replies

Avatar

Correct answer by
Community Advisor

@ST_questions,

You can use the formatDate function to display the date format as MM/DD/YYYY.

{% let d=now %}
{%= formatDate(d, "mm/dd/YYYY") %}

Thanks, Sathees

Avatar

Level 2

Thanks, similar type of syntax is working for me in email body.

 

Want to utilize in the SMS but it is not working.

Updating the offer end date ( now + 30days) in datetime column 

same column passing in the SMS attributes and want date format mm/dd/yy but it is not working. 

Avatar

Level 3

@SatheeskannaK 
It  is also working for me:
{% let d=now %}
{%= formatDate(d, "mm/dd/YYYY") %}

But I need to add +7 days. That is not working. addDates or addDays function does not work. I have tried set days
{% let d = today %}
{%= formatDate(setDays(d,7), "D/MM/YYYY") %}
But it gives wrong output like 217/08/2023

Could you please help? 

@ST_questions 
Have you found any solution? If yes, could you please share it? 

Avatar

Community Advisor

@Zahid_14, Try this,

{% let d = today %}
{% let m=getMonth(d) %}
{% let d1=d.getDayOfMonth()+7 %}
{{ dispMonth }} {{ d1 }} {%= formatDate(d, "YYYY") %}

I haven't tried this yet. I think there is a flaw irrespective of the day it will add 7 days. For example, if today is 25 then it will become 32.

If you find any other solution let me know.

Thanks, Sathees

Avatar

Level 3

@SatheeskannaK 
Thank you so much. I have tried this with 10 days just to see. You are right. In that case it shows 32 :'( 
Still searching for the solution

Avatar

Level 3

@SatheeskannaK 
At last I have found the solution:
{% let d2 = currentTimeInMillis() + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}

Avatar

Community Advisor

@Zahid_14 Thanks for sharing this👍. Consider displaying the formatted date according to the profile timezone if it's something you're interested in.

Thanks, Sathees

Avatar

Level 3

@SatheeskannaK 
Just to let you know that my code only works up to 20 days. For more than 20 days, it shows wrong date 😞 
Do you have any idea or are you aware of any new updates from Adobe? 

Avatar

Community Advisor

@Zahid_14 It should work. Can you share the code to check it from my side?

Thanks, Sathees

Avatar

Level 3

@SatheeskannaK 

Thank you so much. Here is the code used and output:
{% let d2 = currentTimeInMillis() + 15*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}
output: 18/04/2024 
-------
{% let d2 = currentTimeInMillis() + 30*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}
output: 14/03/2024

Avatar

Level 3

But I think it is not problem of Adobe, as if I convert 30 days in mills, it shows like this (https://currentmillis.com/)

Zahid_14_0-1712209329970.png

 

Avatar

Level 2

@Zahid_14 @SatheeskannaK,

Found some solution. Instead of using 30*86400000, multiple these values 30*86400000 = 2592000000. Below is code.
{% let d2 = currentTimeInMillis() + 2592000000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}