Velocity Date Manipulation | Community
Skip to main content
July 3, 2014
Question

Velocity Date Manipulation

  • July 3, 2014
  • 2 replies
  • 950 views
I've got a few date tokens that I've reworked using Velocity, but there are a few issues, the most troubling of which is that the script succeeds in the Marketo email previewer but fails when I send a test email containing it. Look:
 
  1. Parse date to make it manipulable.
    1. #set ($x = ${convert.parseDate($lead.DATEFIELD,"MMM d',' yyyy")})
  2. Compare dates.
    1. $date.difference($x,$date)

This works in the previewer. When I send an email containing anything above, however, I get the script and not its output. I've even tried $convert.toString($x), but that hasn't worked.
 
Can anyone shed some light on what's going on? Thanks!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

July 8, 2014
Hi Wyatt,

passing the date value in a variable and then converting it to a date has compiled properly in my tests.

#set($x = ${lead.DATEFIELD})
<p>Unformatted: $x</p>
#set($x = ${convert.parseDate($x, 'yyyy-MM-dd')})
<p>Converted: $x
<br>
$date.difference($x,$date)
</p>
 
$date.whenIs($x).full
May 5, 2015
I had an issue like this and it turned out I hadn't check the box in the column on the right of the script editor next to the field I was using.