0

The definition for the AMPScript DatePart(D1, S1) function is missing the argument for month name. It reads as follows:

"S1 The part of the date to retrieve. Valid values include year (Y), month (M), monthname, day (D), hour (H), and minute "

Does anyone Know how to retrieve month name?

3 Answers 3

1

If you just want the month name, you can use the Format() function

%%[

var @date1 
set @date1 = Format(Now(), "MMMM")

]%%    
%%=v(@date1)=%%

Output

January

Reference: AMPScript Date and Time Formatting

0
1

You can also use the FormatDate() function. This functions accepts a few additional parameters and is particularly useful when you need to return the month in a different language.

%%=FormatDate(Now(), "MMMM",,"es-ES")=%%    /* -- January -- */

Output

enero

tips: The 3rd parameter is for formatting the time. If no time formatting is needed, pass an null value for this parameter. Also, insure the culture code in the 4th parameter is valid. If an invalid string is passed, it could cause a run-time error.

2
  • Thank you. This response was helpful also. I have a follow-up for you: Is there a list defining all of the culture codes (4th parameter) available?
    – John M
    Commented Jan 18, 2016 at 20:13
  • I haven't found a documented list on SFMC's help site. But, I was able to find a list by googling. "c# culture codes". I would recommend testing each one you plan to use first. All of them may not be supported. reference: msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx Commented Jan 20, 2016 at 16:16
0

Here are the accepted values for the second parameter of the DatePart() function (case insensitive):
y, m, d, h, mi, year, month, monthname, day, hour, minute

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .