I've got an email that uses the following to parse an RSS feed and print the last 5 blog posts. Now they want to print all blog posts from the past week. Any help?

    %%[Var @xml, @titles, @title, @descs,@pubdas,@pubda, @desc, @links, @link, @cnt
Set @xml = ContentAreaByName("my contents\RSSParsej") /* This line specifies the content area from which the RSS content will be pulled for the email message. */
Set @titles = BuildRowsetFromXML(@xml,"//item/title",1)
Set @descs = BuildRowsetFromXML(@xml,"//item/description",1)
Set @pubdas = BuildRowsetFromXML(@xml,"//item/pubDate",1)
Set @links = BuildRowsetFromXML(@xml,"//item/link",1)

If RowCount(@titles) > 5 THEN
SET @rows = 5
SET @rows = RowCount(@titles)

IF @rows >= 1 THEN
for @cnt = 1 to @rows do
Set @title = Field(Row(@titles,@cnt),"Value")
Set @pubda = Field(Row(@pubdas,@cnt), "Value")
Set @desc = Field(Row(@descs,@cnt), "Value")
Set @link = Field(Row(@links,@cnt), "Value") ]%%

<div style="border-bottom: 1px  solid #CBCAD2; padding-bottom:5px; padding-top:3px;">
<a style="text-decoration:none; color: #000000; font-weight: bold; font-size: 16px; font-family: Arial, Helvetica, sans-serif;" href="%%=RedirectTo(@link)=%%" alias="%%=v(@title)="%%" title="%%=v(@title)=%%">%%=v(@title)=%%</a><span style=" font-size:11px; text-decoration:none; font-weight: normal;">     |      %%=Format(@pubda, "MMMM d, yyyy")=%%</span><br/>

NEXT @cnt 
  • We're going to have to know something about how you're getting the date for the blog posts.
    – Timothy
    Commented Jun 3, 2014 at 17:51
  • It's coming from the RSS feed. Here is from the xml: <pubDate>Tue, 03 Jun 2014 14:00:00 GMT</pubDate>
    – Mike
    Commented Jun 3, 2014 at 17:53
  • 1
    This question is totally on topic, this is related to the ExactTarget programming language AMPscript
    – Timothy
    Commented Jun 4, 2014 at 12:45

1 Answer 1


First thing you need to do is drop

If RowCount(@titles) > 5 THEN
  SET @rows = 5
  SET @rows = RowCount(@titles)

Just use SET @rows = RowCount(@titles)

Then you need to add an IF to check the date right after

for @cnt = 1 to @rows do

BUT, you will need to pull out

Set @pubda = Field(Row(@pubdas,@cnt), "Value")

from the current code block so you can check the date.

You can check the date by using DateDiff. It would look like

IF DateDiff(NOW(),@pubda, "D") <= 7

You then would end the IF block right before the NEXT keyword.

Hope this helps.


You must log in to answer this question.

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