Velocity Scripting: Multidate Comparison? | Community
Skip to main content
Casey_Grimes2
New Participant
August 23, 2016
Solved

Velocity Scripting: Multidate Comparison?

  • August 23, 2016
  • 1 reply
  • 1207 views

I have a unique use case where I need to analyze the newest date amongst n values of dates for a Velocity script, but unfortunately, I can't think of any way to do that with multiple values using $date.difference because n is highly variable. I had thought of converting all timedate stamps to Unix epochs and then just finding the highest value, but I don't see any way to do that and thus am stumped.

Is there any reasonable way to do this sort of comparison?

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

Assuming these are actually Date-y Strings:

#set( $dateyList = ['2016-08-21', '2013-04-22', '2017-09-03', '2012-02-01'] )

#set( $dateyList = $sorter.sort($dateyList) )

${dateyList[$math.sub($dateyList.size(),1)]}

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 23, 2016

Assuming these are actually Date-y Strings:

#set( $dateyList = ['2016-08-21', '2013-04-22', '2017-09-03', '2012-02-01'] )

#set( $dateyList = $sorter.sort($dateyList) )

${dateyList[$math.sub($dateyList.size(),1)]}