1

I want to create a dynamic content block using AMPScript as per below conditions

I have a Created Date column in a DE

I want to implement below condition

0-5 days from created date  
show image 1  
6-10 from created date   
show image 2  
11-15   
show image 3  
16-20   
show image 4  
21-25  
show image 1  
26-30  
show image 2  

and so on..

So after 20 days 1st image gets repeated and like that for 4 set of images after every 5 days.

0
2

I don't think it's doable with dynamic content block without using sql and another column to store difference in days between date of send and creation date. You can however use ampscript to achieve that result. Try something like this:

set @createdDate = [created Date]
set @today = SystemDateToLocalDate(Now())
set @dailyDifference = DateDiff(@createdDate, @today, "D")

if @dailyDifference <= 20 then
    set @daysScore = @dailyDifference
else
    set @daysScore = Subtract(@dailyDifference, Multiply(FormatNumber(Divide(@dailyDifference, 20), "F0"), 20))
endif 

if ((@daysScore == @dailyDifference) and (@daysScore == 0)) or (@daysScore >= 1 and @daysScore <= 5) then
    /*Show Image 1*/
elseif @daysScore > 5 and @daysScore <= 10 then
    /*Show Image 2*/
elseif @daysScore > 10 and @daysScore <= 15 then
    /*Show Image 3*/
elseif @daysScore > 15 and @daysScore <= 20 then
    /*Show Image 4*/
endif
1
  • thanks. Used a bit of above, modified and implemented :) – Pankaj Gupta Dec 5 '16 at 23:41

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.