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.

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

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.
Parameter Required/Optional Description
variable Required Item variable to search, passed in using single quotes.
DateMask Optional Flag to specify how partial dates should be handled:
  • If null, ignores partial dates when doing comparisons.
  • If a value is provided (in string format), replaces the UNK component in the partial date with the specified value.

    For example: entering '10-Apr' substitutes with '10' every UNK value of Day (DD) component and with 'Apr' every UNK value of Month (MMM) component.

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"))

Examples

Example 3-67 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";