SOLVED

Velocity Scripting: Multidate Comparison?

Go to solution
Casey_Grimes
Level 10

Velocity Scripting: Multidate Comparison?

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Multidate Comparison?

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)]}

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting: Multidate Comparison?

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)]}