Incrementing Dates with Velocity Scripting

Not applicable

Incrementing Dates with Velocity Scripting


My goal is to use Velocity Scripting within a Script Token to access a date value stored in a custom object, format the date and increase it by one week (maybe not in that order).  So far I have been able to access and format the date, but I am struggling changing the date value.

Within my data it is possible to have multiple custom objects, so first I identify the desired object, then pull and format the date like so:

#set ($wlLeadSourceWL = "1409127")

#foreach ( $GCWFD_c in $GCWFD_cList )

  #if ($wlLeadSourceWL == ${GCWFD_c.wlLeadSource})

        #set($dueDate = ${GCWFD_c.WLutmDateTime})

        #set($dateObj = $date.toDate("yyyy-MM-dd", $dueDate))

        #set($dateFormatted = $date.format("EEEE, MMMM d, yyyy", $dateObj))



I have seen examples of adjusting the date, but nothing seems to be working for me. Can someone please assist me or at least point me in the right direction?

Let me know if you need additional information or have any questions.

Thanks in advance for your time and help!



Not applicable

Re: Incrementing Dates with Velocity Scripting

Hi Reed,

My response is bit late, hence not sure if you got the solution to your problem or not?

This is bible that I have always used for date manipulation - DateTool (VelocityTools 2.0-beta4 Documentation)

Another link that might be helpful - Adding Days and Comparing Dates

You can easily do math operations on date in velocity scripting.

Instead of formatting the date and then adding 7 days, is it possible for you to get current date, add 7 days and then format the final result?

Hope these above pointers help!