Please help me to calculate dates.
I have two date fields.
Date1 ( Date Application Received)
Date2 (Program Date)
In Adobe Acrobat pro in forms,text field properties, calculate tab, simplified notation, I entered (DateAppRec-PROGRAMDATE.
I get a error Nan. ( not a number)
How can I calculate two dates using the simplified notation?
Thank you in advance of your help.
Best
Louisa
// Custom Calculate script
// Get the input field values
var s1 = getField("Date1").valueAsString;
var s2 = getField("Date2").valueAsString;
if (s1 && s2) {// Convert date strings to date objects
var d1 = util.scand("mm/dd/yyyy", s1);
var d2 = util.scand("mm/dd/yyyy", s2);
// Set this field value to the difference in days
// 864e5 = 86400000 = 1000 * 60 * 60 * 24 = number of milliseconds in a day
event.value = Math.abs(Math.round((d2 - d1)/864e5));
} else {
// Blank this field if either inputs are blank
event.value = "";
}
You may need to use a different format string in the util.scand lines so they match the format of your fields.