I have 12 content blocks (for every month of the year) and would like to change the content on the 1st of every month. How do I accomplish this?

2 Answers 2


I have assumed that you create ContentBlocks for every month and name them with a pattern so you can code it very easily. For the code that is presented below you would need 12 different content blocks that are named:

  • ...

Be aware of the fact that there is a limit of characters when you would use ContentBlockByKey


/* Do variable declaration at the top for best practices */ 
var @today, @month, @contentBlockToGet

/* Be aware of the difference between now() and now(1). Especially with VAWP */ 
/* Watch resources list below for Now() */
/* Now delivers the time in CET, which has to be transferred to the right timezone for the user, otherwise there might be problems, Watch resources list below for SystemDateToLocalDate() */ 
set @currentSystemTime = now(1)
set @today = SystemDateToLocalDate(@currentSystemTime)
set @month = DatePart(@today, "M")
set @contentBlockToGet

/* Just to test if Salesforce DatePart is correct :D */
IF @month >= 1 and @month <= 12 THEN
    set @contentBlockString = Concat("AWESOME_CONTENT_MONTH_",@month)

/* Somewhere Inside the Newsletter/Email */
/* To make it failsafe you can also create default content when your contentblock might not exist you would include additional parameters 
https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/contentblockbykey.htm */

/* OR */ 


  • Thank you Johannes - looks good - i will test this and let you know.
    – REZA Y
    Jun 28, 2019 at 17:21

this below code use for getting 1st of every month try like this based on that you can display the content or post your code here what did try so far


 set @today = now()
 set @monthOfThisMonth = DatePart(@today, "M")
  set @yearOfThisMonth = DatePart(@today, "Y")
   set @firstDayOfThisMonth = 
  @today: %%=v(@today)=%%
 <br>@monthOfThisMonth: %%=v(@monthOfThisMonth)=%%
 <br>@yearOfThisMonth: %%=v(@yearOfThisMonth)=%%
 <br>@firstDayOfThisMonth: %%=v(@firstDayOfThisMonth)=%%
  • This answer is not targeting the problem. The questioner wants to change content, he/she does not want to display dates. Atleast thats what the question tells us. Your code therefore offers only the way to get the current month. After that the code should use elseifs with ContentblockBy<ID/Key/Name> Jun 28, 2019 at 6:44
  • @ Johannes Schapdick--> thats why iam asking him post your code here like that ok
    – Ravi.A
    Jun 28, 2019 at 6:46
  • This is just not the right blueprint. Jun 28, 2019 at 6:48
  • Thank you - the intent is to display the content blocks that are already built and labeled in an email on the first of every month..
    – REZA Y
    Jun 28, 2019 at 17:19

You must log in to answer this question.

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