Compare three date fields and and select the latest date.
Can someone assist with a calculation script that complares three different date fields and then returns the latest date of the three? Thanks!
Can someone assist with a calculation script that complares three different date fields and then returns the latest date of the three? Thanks!
Are you getting 3 dates from fields?
Here is example(change field names to your actual field names):
var date1 = this.getField("Date1").valueAsString;
var date2 = this.getField("Date2").valueAsString;
var date3 = this.getField("Date3").valueAsString;
var d1 = util.scand("mm/dd/yyyy", date1);
var d2 = util.scand("mm/dd/yyyy", date2);
var d3 = util.scand("mm/dd/yyyy", date3);
var n1 = d1.getTime();
var n2 = d2.getTime();
var n3 = d3.getTime();
var h = Math.max(n1,n2,n3);
if(date1 == "" || date2 == "" || date3 == "")
event.value = "";
else if(h == n1)
event.value = date1;
else if(h == n2)
event.value = date2;
else if(h == n3)
event.value = date3;
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.