0

I am a beginner in AMPscript and I am facing an issue. I would like to convert a date format into the customer language. For now, I was able to convert the format from "xx/xx/xxxx" into "DD MMMM YYYY" doing this:

SET @EB1_End_Date_Formated = FormatDate(@EB1_End_Date, "DD MMMM YYYY","", "en-US")
SET @Opening_Date_Formated = FormatDate(@Opening_Date_Formated, "DD MMMM YYYY","", "en-US")

but now I would like the formatted date to be translated into the customer language for it to do:

  • English: 21 december 2021
  • French: 21 décembre 2021

Can you please help me with this? I cannot find the exact code to enter anywhere. Thanks a lot!

1 Answer 1

0

You basically have everything to achieve the desired result. Since you already have the English date version, then that is how the FormatDate function would look for the French version, you just change the 4th and last argument to the ISO locale code -

/* I gave a new name for French variables */
SET @EB1_End_Date_Formated_FR = FormatDate(@EB1_End_Date, "DD MMMM YYYY","", "fr-FR")
SET @Opening_Date_Formated_FR = FormatDate(@Opening_Date_Formated, "DD MMMM YYYY","", "fr-FR)

You can find the list of all existing in Marketing Cloud locales here.

A small tip on top, you can use ProperCase function to make sure the month's name will be always starting with a capital letter -

SET @EB1_End_Date_Formated_FR = ProperCase(FormatDate(@EB1_End_Date, "DD MMMM YYYY","", "fr-FR"))
SET @Opening_Date_Formated_FR = ProperCase(FormatDate(@Opening_Date_Formated, "DD MMMM YYYY","", "fr-FR))
3
  • thanks a lot Niko! However I don't know how to place it within my ampscript for it to work, it seems something is missing... I just put it after the EN ? nothing more? Nov 16, 2021 at 14:25
  • Not sure if I understood your issue correctly. You need to change only the last 4th argument in the function to another ISO locale. "en-US" --> "fr-FR" as an example. What is the problem with the placement though?
    – Niko
    Nov 16, 2021 at 14:42
  • @AndreaJuan so have you solved your problem?
    – Niko
    Nov 18, 2021 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.