Expand my Community achievements bar.

Adobe Journey Optimizer Community Lens 6th edition is out.
SOLVED

Format Date Issue

Avatar

Level 3

I am tryign to use the following code:

{% let newDate = profile._loyaltyone.onboardingJourney.firstOffer.endDate %}
New Date = {%= newDate %}


which returns the following:

New Date = 2024-05-12T00:00:00Z

 

I would like to format as "May 12, 2024" but my code is not working:

New Date = {%= formatDate(newDate, "MMMM dd,YYYY") %}

Invalid syntax Usage of function "formatDate" does not match available signatures. Usage: [PQLSchemaImplJson({"meta:xdmType":"date"}), PQLSchemaImplJson({"meta:xdmType":"string"})] Signatures: [(List(PQLSchemaImplJson({"meta:xdmType":"date-time"}), PQLSchemaImplJson({"meta:xdmType":"string"})),PQLSchemaImplJson({"meta:xdmType":"string"})), (List(PQLSchemaImplJson({"meta:xdmType":"date-time"}), PQLSchemaImplJson({"meta:xdmType":"string"}), PQLSchemaImplJson({"meta:xdmType":"string"})),PQLSchemaImplJson({"meta:xdmType":"string"}))]


I know I am doing something wrong, just not sure what.


1 Accepted Solution

Avatar

Correct answer by
Employee

You can try the following

{% let newDate = profile._loyaltyone.onboardingJourney.firstOffer.endDate %}
{%= formatDate(toDateTimeOnly(newDate), "LLLL dd, YYYY") %}

View solution in original post

4 Replies

Avatar

Community Advisor

@connorSlack24 Try something along these lines,

 

{% let d=profile._loyaltyone.onboardingJourney.firstOffer.endDate %}

    {% let m=getMonth(d)%}

    {% let dispMonth=""%}

    {%#if m=1 %}

    {% let dispMonth="Jan"%}

    {% else if m=2 %}

    {% let dispMonth="Feb"%}

    {% else if m=3 %}

    {% let dispMonth="Mar"%}

    {% else if m=4 %}

    {% let dispMonth="Apr"%}

    {% else if m=5 %}

    {% let dispMonth="May"%}

    {% else if m=6 %}

    {% let dispMonth="Jun"%}

    {% else if m=7 %}

    {% let dispMonth="Jul"%}

    {%/if%}

    {{ dispMonth }} {%= formatDate(d, "dd, YYYY") %}

Thanks, Sathees

Avatar

Level 3

This did not work for me, but the solution posted below did (we have found that toDateTimeOnly function AFTER I posted the help)

 

Avatar

Correct answer by
Employee

You can try the following

{% let newDate = profile._loyaltyone.onboardingJourney.firstOffer.endDate %}
{%= formatDate(toDateTimeOnly(newDate), "LLLL dd, YYYY") %}