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!
Solved! Go to Solution.
Views
Replies
Total Likes
I have found a solution for calculated dates:
{% let d2 = currentTimeInMillis() + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}
Haven't experienced this yet. Please reach out to clientcare@adobe.com
Hi @maggod , you could try a profile script similar to one show in the document here (this will have to be done in Target):
Views
Replies
Total Likes
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Setdays is not right function to use in the scenario mentioned , try with nowwithdelta function
@Anuhya-Y ,
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?
Views
Replies
Total Likes
@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.
@Anuhya-Y
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.
I have found a solution for calculated dates:
{% let d2 = currentTimeInMillis() + 14*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}
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") %}
@Zahid_14 It gives me the correct date till the 24th future date. If I am giving 25th days from today or more than that it gives me past days/wrong date.
{% let d2 = currentTimeInMillis() + 30*86400000 %}
{% let ourDate = toDateTimeOnly(d2) %}
{%= formatDate(ourDate, "dd/MM/yyyy") %}
Expected Output: 01/08/2024
Output I am getting: 12/06/2024
is there any other way to achieve the correct future dates.
Views
Replies
Total Likes
@NiteshSingh, AJO is not doing the millisecond multiplication correctly for beyond 24 days (24*86400000). The reason it is showing past date in output for days greater than 24 days is, multiplication is giving value in -ve.
To get the correct value for days greater than 24 day, do the calculation on calculator and pass the hardcoded value in it.
Did you get any solution for this to calculate "profile.mydate + 100 days"?
Regards,
Abhishek
Views
Replies
Total Likes
I was able to add thirty days to the date+time field from the AEP dataset by first converting the attribute's year, month, and day to the milliseconds and then subtracting the milliseconds elapsed from the epoch time from each. Then add them all up and then also add the 30 days converted to milliseconds at the very end, the last "2592000000" value.
{% let someDate = "insert the profile date attribute here" %}
someDate_from_ds: {%= someDate %} <br/>
{% let someDate_inMillis = (someDate.getYear() * 31556952000 - 62167195440000) + (someDate.getDayOfMonth() * 86400000 - 86400000) + (someDate.getMonth() * 2629746000 - 2629746000) + (2592000000) %}
someDate_inMillis: {%= someDate_inMillis %}<br/>
{% let someDate_inMillis_formatted = toDateTimeOnly(someDate_inMillis) %}
someDate_formatted_final_plus30_days: {%= formatDate(someDate_inMillis_formatted, "MM/dd/YYYY") %}
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies