How can I get the previous month using AMPscript, based on current month eg: I have a text in the message, where I mention the previous month like, "Dear (name) follow the report regarding (May)" but This email will be sending in June.

So, I'd like to replace May for %%currentmonth(-1)%% something like that.


You can do something like this:

%%=datepart(dateadd(now(1), -1, "M"),"monthname")=%%



The now(1) function returns the current date, dateadd() allows you to move forward and back on the date by the specified qualifier and datepart() will extract parts of the date.


  • Thank you so much Adam, It worked! just one more question, Is it possible to show it in portuguese? Abril instead april. – Patrik Lemos May 18 '18 at 11:01

You can use this code to show it in Portugese, or any other language, based on the locale:

%%=FormatDate(dateadd(now(1), -1, "M"), "MMMM",,"pt-PT")=%%

You cannot ignore the third parameter of the formatDate function. You need to pass something there to get to the fourth parameter. Even if its a null object like my below example:

%%=FormatDate(dateadd(now(1), -1, "M"), "MMM,YY",,"pt-PT")=%%
  • I Got it, Just one more question, is it possible to hide the comma between month and year? Just Showing "Jun19" together, Thank you so much! – Patrik Lemos Jul 2 at 20:35
  • %%=FormatDate(dateadd(now(1), -1, "M"), "MMMYY",,"pt-PT")=%% Just remove the comma then and write it together. Please try out stuff on your own which is kind of straigth forward instead of just always asking. – Johannes Schapdick Jul 3 at 6:13
  • thanks Johannes, and sorry about asking many questions. – Patrik Lemos Jul 3 at 11:42
  • No worries, just make sure to show something you have tried. We are interested that everyone gets better and does not see this forum as a place where you can just post every question where you have not tried to solve it on your own. If you try something and someone guides you in the right direction its more rewarding for both sides. – Johannes Schapdick Jul 3 at 11:46

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.