AnsweredAssumed Answered

Dates comparison in mapping in javascript

Question asked by sulochana.dasari636529 on Nov 21, 2017
Latest reply on Nov 21, 2017 by sulochana.dasari636529

Hi, I am trying to compare Start Dates of Compound Employee XML and get the latest date in the return field from javascript.   These start dates are from Address, Personal Information, Job, Compensation and Paycompensation recurring nodes of compound employee.I can see all the data from each start date field being passed to script but nothing is returned from the script output. I have added my code and tested but nothing is returned from the function output. Can any one please help me with the code.   

 

 

Code:

 

var dates = [Ain,Pin,Cin,Jin,Payin];
var max = dates[0];
for(var i = 1; i < dates.length; i++) {
if (fDate(dates[i]) > fDate(max))
max = dates[i];
}
//alert(max);
// create a proper Date object from the string
function fDate(s) {
var d = new Date();
s = s.split('/');
d.setFullYear(s[2]);
d.setMonth(s[1]);
d.setDate(s[0]);
return d;
}

 

I am trying to output 'd' from the code.

Outcomes