I am currently using Marketo and we want to pull through some data by looking at the date when the custom object information was entered.
I know php, javascript etc but Velocity is a new thing, although familiar I can't work out the best way to compare dates.
In the code below I have tried two ways, using the Number Tool or Date Tool but have not had much luck. ##Get all the custom object data #set( $items = ${customerPurchaseData_cList} )
#set( $currentDateNumber = $number.toNumber('25/01/2016') )
#set( $startDateNumber = $number.toNumber($item.orderDate) )
$currentDateNumber
$startDateNumber
#if( $startDateNumber <= $currentDateNumber )
## if the date is current date is less than do something
#end
#set($cal1=$date.toCalendar('25/01/2016'))
#set($strDate1=$date.format('MM/dd/yyyy hh:mm:ss a',$cal1))
##set($cal1 = $cal1.get('yyyy-M-d H:m:s'))
#set($calCompare=$item.orderDate.compareTo($strDate1))
<ul>
#foreach ( $item in $items )
#if ($calCompare > 0)
<li>$item.MetalType</l1>
#end ##end of if statement
#end ##end of foreach
</ul>
## > $date.get('2017-01-01')
### if ($item.orderDate > $date.get('2017-01-01'))
Is there an easy way to compare the date values? Such as turning them into UNIX Timestamps?
Your help would be amazing!
Have a look at the Class ComparisonDateTool
in the Velocity Apache API: Click here.
As long as you have the dates in the correct format you should be able to compare the two and get the values you need to run an if statement on them.