Printing dates on Velocity | Community
Skip to main content
July 26, 2018
Solved

Printing dates on Velocity

  • July 26, 2018
  • 1 reply
  • 1859 views

Hi,

I'm currently trying through a script token, calculate the difference in days, between two dates and display them on an email. The problem that I have is that when trying to print the result i'm just getting the variable name.

Here's my script token code:

#set($test = ${lead.DateofBirth})

#set($test2 = $test.length())

#set($leadAcquisition = ${lead.Acquisition_Date})

#set($acquistionString = $leadAcquisition.substring(0,10))

#set($dateDifference = $date.difference('2018-05-05', '2018-04-04').toString())

Here's my the section of the Email where I'm trying to print the values:

<div>

         TEST $test TEST2 $test2 LeadAcquisition $leadAcquisition AcquisitionString $acquistionString DateDifference $dateDifference

</div>

But this is my output:

TEST 1986-08-16 TEST2 10 LeadAcquisition 2018-07-23 17:35:00 AcquisitionString 2018-07-23 DateDifference $dateDifference

I have tried printiing other values accesible from the DateTool and DateComparison tool with no success. So I'm thinking that maybe I'm not calling the methods correctly because others seem to work.

Anyone have a clue of what could be the problem and a possible solution?

Thanks in advance.

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

Please read this post, the seminal post on date math in Velocity: https://blog.teknkl.com/velocity-days-and-weeks/

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
July 26, 2018

Please read this post, the seminal post on date math in Velocity: https://blog.teknkl.com/velocity-days-and-weeks/

July 27, 2018

Really helpful, thank you very much