SOLVED

Printing dates on Velocity

Go to solution
Anonymous
Not applicable

Printing dates on Velocity

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.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Printing dates on Velocity

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

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Printing dates on Velocity

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

Anonymous
Not applicable

Re: Printing dates on Velocity

Really helpful, thank you very much