Recent date from an array of dates.

Jira Code: DB-14
This function is to get the recent date from an array of dates. This can be used to find the ‘Expected receipt date’ from a PO if there is multiple POs for an item.

     // TO GET THE RECENT DATE
for (var j = 0; j < searchResultPO.length; j++) {
              date_arr.push(expected_date)
}
                        var max_dt = date_arr[0],
                            max_dtObj = new Date(date_arr[0]);
                        date_arr.forEach(function(dt, index) {
                            if (new Date(dt) < max_dtObj) {
                                max_dt = dt;
                                max_dtObj = new Date(dt);
                            }
                        });
                        log.debug('max_dt', max_dt)

Leave a comment

Your email address will not be published. Required fields are marked *