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.
SOLVED

Date Time functions, add days?

Avatar

Level 4

Any tipps how I can add a given amount of days to a given datetime profile attribute?

 

E.g.

profile.mydate + 100 days

Thursday, 11 November 2021 + 100 days = Saturday, 19 February 2022

 

I checked https://experienceleague.adobe.com/docs/journey-optimizer/using/personalization/functions/dates.html... but couldn't find a way to achieve this.

 

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Level 2

I have found a solution for calculated dates:
{% let d2 = currentTimeInMillis() + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}

View solution in original post

13 Replies

Avatar

Community Advisor

Haven't experienced this yet. Please reach out to clientcare@adobe.com 

Avatar

Level 4

Hi @maggod , you could try a profile script similar to one show in the document here (this will have to be done in Target): 

https://experienceleague.adobe.com/docs/target/using/recommendations/recommendations-faq/recommendat... 

Avatar

Employee Advisor

hey @maggod  can you help me to understand the usecase? Is this for a condition check, or you are trying to append data? Or just format/change a string? 

Avatar

Level 4

Hi Ivan

 

I wanted to render some personalized text into AJO message content.

Example:

"Your contract will end Sept 1st 2022".

"Sept 1st 2022" should be calculated based on a profile attribute (like "contract/abc/contractStartDate") plus 2 years.

 

 

Avatar

Level 1

Hi, I'm currently trying to do the exact same thing (add 7 days to a dateTime field to get a new dateTime that is 7 days in the future). Is there already a solution or workaround for this? 

Avatar

Level 2

I am also trying to do the same thing. But it does not work. Please help me if anyone knows the solution. 
I tried to use it:
{% let d = today %}
{%= formatDate(setDays(d,7), "D/MM/YYYY") %}
but shows like this if today is 21st August, it will show 217-08-2023

Avatar

Level 2

@anuhya-tad , 
Thank you so much for your suggestion. I have also tried with now with delta function. It says unknown function error. Do you know any detailed documentation? May be i am using it in a wrong way? 

Avatar

Level 7

@Zahid_14  I tested nowwithdelta function now, seeing the same error "unknown function". I would recommend please reach out to Adobe support on this issue and do share the solution here once you have.

Avatar

Level 2

@anuhya-tad 
Thanks for checking. I have already submitted a ticket. It seems this function is not available (Calculated date). There is another way but it also gives wrong date like if you add 10 days today, it will show 32-August-2023. 

Avatar

Correct answer by
Level 2

I have found a solution for calculated dates:
{% let d2 = currentTimeInMillis() + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}

Avatar

Level 2

How to convert the specific date attribute value into milliseconds. So that we will use that attribute instead of currentTimeInMillis() like

{% let d2 = profile.dateAttribute + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}