[SalesForce] AMPscript Date formatting using format or formatdate not working

I have an ORDER_DATE attribute in my data extension which is of the text datatype. The date is in the following format mm-dd-yyyy.

Now I want to convert this date into European format based on locale but I am getting some error while converting it.

I am using the following piece of code:

%%[

  var @orderDate 
  set @orderDate = ORDER_DATE
  set @convertdate = FormatDate(@orderDate,"l","","en-GB") 
  Output(Concat("OrderDate: ", @convertdate))

]%%

Why the date is not showing me when I do preview and test??

Best Answer

Depending on how your text dates are formatted, you many need to do some string manipulation before applying the formatting:

%%[

  var @orderDate 
  var @convertDate

  set @orderDate = AttributeValue("ORDER_DATE")
  output(concat("<br>orderDate: ", @orderDate))  

  set @convertdate = FormatDate(replace(@orderDate," ",""),"l","","en-GB") 
  output(concat("<br>convertdate: ", @convertdate))

]%%
Related Topic