Next of three dates with empty handling

0
Hi all,  I have an object with three dates, and a report which will need to check which of three dates is the next date and return it as Date 4.  This logic does this fine: (Thank you Tim van Steenbergen) if ($MyObject/date1 > [%EndOfCurrentDay%]     and $MyObject/date1 < $MyObject/date2     and $MyObject/date1 < $MyObject/date3)     then $MyObject/date1     else if ($MyObject/date2 > [%EndOfCurrentDay%]              and $MyObject/date2 < $MyObject/date3)            then $MyObject/date2            else if $MyObject/date3 > [%EndOfCurrentDay%]                    then $MyObject/date3                    else somedefaultdate The issue is when dates are empty, if throws errors.  So I need something that will check each of the dates, discount any that are empty and any that are in the past. Of the dates left find which is the next date and return it to Date 4. If all dates are empty or in the past then it returns nothing, this is fine as the report will ignore any empty date 4 fields. 
asked
1 answers
4

You could do it step by step:

If date 1 is not empty and not in the past set day 1 as result. Otherwise, set result to empty.
If date 2 is not empty and not in the past {if result is empty set result to date 2, else if date 2 < result set date 2}
If date 3 is not empty and not in the past {if result is empty set result to date 3, else if date 3 < result set date 3}
If date 4 is not empty and not in the past {if result is empty set result to date 4, else if date 4 < result set date 4}

If each date was empty, your result will also be empty. If not, your result contains the smallest date.

answered