I am looking to show the date in two different formats based on locale (the locale variable is set to LocaleCode earlier in the email). For en-US it should be January 1, 2021 and all other locales it should be 1 January, 2021. The actual date is being pulled from a data extension and I have it formatted for en-US currently. What I am trying to do is change the format based on the locale. Here is what I have tried (among other things) but it's still not displaying.
TrialEndDate pulls a date from a data extension: SET @TrialEndDate = [ExpirationDate]
%%[
IF @locale == "en-US" then
SET @date=TreatAsContent(FormatDate(@TrialEndDate, "MMMM d, yyyy"))
ELSE
SET @date=TreatAsContent(FormatDate(@TrialEndDate, "d MMMM, yyyy"))
ENDIF
]%%
%%=v(@date)=%%
I had also tried this, without the TreatAsContent
function:
%%[
IF @locale == "en-US" then
SET @date="%%=FormatDate(@TrialEndDate, "MMMM d, yyyy")=%%"
ELSE
SET @date="%%=FormatDate(@TrialEndDate, "d MMMM, yyyy")=%%"
ENDIF
]%%
%%=v(@date)=%%
@TrialEndDate
?[ExpirationDate]
a Date data type?