WhenIs not returning expected value | Community
Skip to main content
November 12, 2015
Question

WhenIs not returning expected value

  • November 12, 2015
  • 1 reply
  • 1752 views

Working on an Email Script Token, and it is not returning the expected value.

As best as I can tell from looking at examples this should return -3, but it is returning $date.whenIs($myDats).days instead.

The field in the custom object is defined as date

Current Date I am writing this : 2015-11-12

#foreach($loan_c in $loan_cList)

   #set($myDays = ${loan_c.sAPStatusDate})

   <tr>

      <td>${loan_c.sAPStatusDate}</td>

      <td>$date.whenIs($myDays).days</td>

   </tr>

#end

Output:

2015-11-09    $date.whenIs($myDays).days

Anyone have any idea why it is not displaying -3?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

August 15, 2016

No matter what I tried, I had to use convert.parseDate to convert dates into a 'real' date for use with whenIs.

#set($myVar = $convert.parseDate(${myVar},'yyyy-MM-dd'))

$date.whenIs($myVar).days

August 15, 2016

Yep, dates are exported to Velocity as strings, so this is expected.  You're doing the right/only thing.

See also my comments here: https://nation.marketo.com/blogs/marketowhisperer/2016/08/14/velocity-script-tokens-as-an-alternative-for-dynamic-conten…

(Unfortunately posting from my second account but it's the same ​Sanford.)