These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

calculation the number of days using two date fields

needtechadvice
Registered: Jan 24 2010
Posts: 11

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

My Product Information:
Acrobat Pro Extended 10.1, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
You can't using simplified field notation. Fortunately you can use JavaScript:

// 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.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can't. It requires a more complex script.
Basically you need to convert both values to a Date object, and then you can calculate the difference between them.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

needtechadvice
Registered: Jan 24 2010
Posts: 11
Thank you for your response.
Can I send you the document?
I dont know how to input this in PDF for java script.
my email is loulikesthis [at] gmail [dot] com.
If you send your email I'll send you the document.
This will show me how to input Java script in a document.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
There are a number of tutorials here that cover this in greater detail. The following two will get you started:

http://acrobatusers.com/tutorials/2006/form_calculations

http://acrobatusers.com/tutorials/2006/date_time_part1