Find the Latest Date in a List

From HotDocs Wiki

Jump to: navigation, search

When you have repeated variables in your templates, you may want to find which value meets a certain condition. For example, if you have a list of revision dates, you may want to determine which date is latest.


In this example, the dialog containing a Date variable is repeated. The result of the computation is initialized with the first answer in the list, and in each subsequent repetition, if the date is greater (later) than the result, the result is set to that date. After all repetitions are processed, the result is the latest date in the list.

In this computation, Date Var is any Date variable in Repeat Dialog. Repeat Dialog is any repeated dialog containing a Date variable.

Date Var 
REPEAT Repeat Dialog 
  IF Date Var > RESULT 
    Date Var 
  END IF