Conditional content in a recuring delivery based on curent date | Community
Skip to main content
June 24, 2025
Solved

Conditional content in a recuring delivery based on curent date

  • June 24, 2025
  • 1 reply
  • 674 views

Hello,

 

I want to create a recurring delivery with content that varies depending on the date.
I would like to be able to display the "July" block only in July and the "August" block only in August.
Do you know what conditions I have to put in my HTML to have a structure like this:
- Generic content
- If the date is after 01/07/25 and strictly before 01/08/25 then "July Block"
- If the date is after 08/01/25 and strictly before 09/01/25 then “August Block”
- Generic content

 

I don't know how to setup the conditions in red below :

<% if ( curentdate > "01/07/2025 00:00:00" && curentdate < "01/08/2025 00:00:00" ) { %>July Block<% } %>

 

Thank you in advance for your help.

Arthur

Best answer by ParthaSarathy

@arthur_le_bris_u-tech , You can try the below,

<body> <% var currentDate = new Date(); var Date1 = new Date('2025-07-15'); var Date2 = new Date('2025-08-22'); var Date3 = new Date('2025-08-23'); var Date4 = new Date('2025-08-30'); %> <% if (currentDate >= Date1 && currentDate <= Date2) { %> <p>Content for Block 1 : from 15/07/25 to 22/08/25</p> <% } %> <% if (currentDate >= Date3 && currentDate <= Date4) { %> <p>Content for Block 2 : from 23/08/25 to 30/08/25</p> <% } %> <% } else { %> <p>Default content block if any</p> <% } %> </body>

1 reply

ParthaSarathy
Community Advisor
Community Advisor
June 24, 2025

Hi @arthur_le_bris_u-tech ,

You can use formatDate and get the 'month' value for personalization,

<% if ( formatDate(new Date(), "%2M") == '01' ) { %> Insert content here for January Month <% } %>

 

~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
June 25, 2025

Hi @parthasarathy,

Thank you for this answer which responds exactly to the use case described.
However, I realize that my request was poorly worded because my case is a little more complex.

I would like to be able to display the block between 2 given dates (not necessarily a full month).
For example:

- Block 1 : from 15/07/25 to 22/08/25

- Block 2 : from 23/08/25 to 30/08/25


Thanks

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
June 25, 2025

@arthur_le_bris_u-tech , You can try the below,

<body> <% var currentDate = new Date(); var Date1 = new Date('2025-07-15'); var Date2 = new Date('2025-08-22'); var Date3 = new Date('2025-08-23'); var Date4 = new Date('2025-08-30'); %> <% if (currentDate >= Date1 && currentDate <= Date2) { %> <p>Content for Block 1 : from 15/07/25 to 22/08/25</p> <% } %> <% if (currentDate >= Date3 && currentDate <= Date4) { %> <p>Content for Block 2 : from 23/08/25 to 30/08/25</p> <% } %> <% } else { %> <p>Default content block if any</p> <% } %> </body>
~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups