findMinDateIn2SForm( )

Find the minimum value of given date, date-time, or partial date items in all repeating instances of a two-section form. This function is only applicable to date fields.

Note:

This is an aggregation function. The rule is run for each instance in the case where the target is on the repeating section of a two-section form.

Syntax

findMinDateIn2SForm('variable', DateMask)

Parameters

variable
Rule variables, with reference path: eventId.formId.itemId.

Note:

It is allowed to reuse variables passed into this function elsewhere in the rule expression, however you must add the variable as a parameter using single quotes.
DateMask
Optional. Date mask to use for substitution for partial dates. If not provided, partial dates are excluded from the calculation.

Note:

Use mask only for date elements and do not use it for time elements. Any missing value in the time part is considered as 00.

Return value

  • Minimum date value in String format. For example, '27-Jan-2021 00:00'.
  • null if minimum is not found.

Usage tips

  • Use 'DD-MON' format as DateMask to substitute unknown (UNK) values in the partial date values. For example, if the mask is '01-MAR':
    Partial date value Masked date Notes
    'UNK-FEB-2020' '01-FEB-2020' Made effective for calculation using the day part of the mask.
    'UNK-UNK-2020' '01-MAR-2020' Made effective for calculation using both, the day and month parts of the mask.
  • To convert return value to JavaScript date object, extra formatting should be done. For example:
    vExample = '10-Jul-2022 10:UNK:UNK'  
    new Date(vExample.replace(/UNK/g, "00"))

Example 3-65 Get the minimum date value for an item across a set of repeating section instances on a two-section form

// Get the minimum date value for an item across a set of repeating section instances on a two-section form
 
return findMinDateIn2SForm('aeDate');
 
// Same as above, using a partial date field aeDate (UNK-MMM-YYYY)
 
return findMinDateIn2SForm('aeDate', '01-JAN');
 
//to compare with another date
var mind= findMinDateIn2SForm('a');
var today = new Date();
var mindate = new Date(mind);
if(dateDiffInDays(today,mindate)>0){
   return "today>min";
}
return "today<min";