Format Date Issue | Community
Skip to main content
June 19, 2024
Solved

Format Date Issue

  • June 19, 2024
  • 2 replies
  • 1052 views

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.


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 Mohan_Dugganab

You can try the following

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

2 replies

SatheeskannaK
Community Advisor
Community Advisor
June 20, 2024

@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
June 21, 2024

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

 

Mohan_Dugganab
Adobe Employee
Mohan_DugganabAdobe EmployeeAccepted solution
Adobe Employee
June 21, 2024

You can try the following

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

Worked, thank you!