Using velocity script to pull data from custom object based on a time period.

Highlighted

Using velocity script to pull data from custom object based on a time period.

Hi,

I'm building out a dynamic email that should render content for members after a specific anniversary date, which is from a custom object data.

I can code it to match up with a specific date value using the equal operator, but it does not work with the greater then or less then operator. I'm trying to code it for "After" or "Before" a specific date.

Here is a sample code that works if we use equal operator:

#foreach($partner in $partner_cList)

#set ($AnniversaryDate = $date.toDate("yyyy-MM-dd", ${partner.enrollmentEndDate}))

#set ($Date1 = $date.toDate("yyyy-MM-dd", "2019-10-01"))

#set ($Date2 = $date.toDate("yyyy-MM-dd", "2019-10-30"))

#if($AnniversaryDate >= $Date1)

show this content

#break

#else

#end

1 REPLY 1
Highlighted
Level 10 - Community Moderator

Re: Using velocity script to pull data from custom object based on a time period.

  1. Have you read the seminal post on date and time methods in Velocity ?
  2. Please always highlight code when posting to the Nation:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif