Velocity Code Date Subtract with Math
Hi. We have a membership-based organization.
We have field data for $lead.aornPaidThru date. This is the member's renewal date.
I am trying to subtract 89 days from the $lead.aornPaidThru date to display a date that's 90 days in advance of the member's renewal date.
I'm not that familiar with Velocity (probably obvious).
Here's what I've put together, but it is not working. I do not have a developer available to assist with this, so I'm hoping for a little help here from the community, please.
When I run this in a Marketo email with a member, all that displays for the token result is:
aornPaidThru is not in the future
#set( $DAYS_OFFSET_BASE = 89 )
#set( $ret = $calNow.set(
$calNow.get($calConst.YEAR),
$calNow.get($calConst.MONTH),
$calNow.get($calConst.DAY_OF_MONTH),
0,
0,
0
) )
#set( $ret = $calNow.set($calConst.MILLISECOND,0) )
#set( $calRenewDate = $convert.toCalendar(
$convert.parseDate(
$lead.aornPaidThru,
$ISO8601DateOnly,
$defaultLocale,
$defaultTimeZone
)
) )
#set( $daysUntilRenewDate = $date.difference($calNow,$calRenewDate).getDays() )
#if( $daysUntilRenewDate > 0 )
#set( $daysOffsetFromBase = $math.sub($DAYS_OFFSET_BASE, $daysUntilRenewDate) )
aornPaidThru offset is $daysOffsetFromBase.
#else
aornPaidThru is not in the future.
#end