Need Java Script for Calculation of Number Days between 2 dates
Copy link to clipboard
Copied
Need Java Script for Calculation of Number Days between 2 dates. Using Adobe Acrobat Pro DC and creating a fillable form.
MatDate1 - IssueDate1 = Number of Days
Thanks!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you for the links, however, I was unable to piece together exactly what I am needing. I know very little about javascript writing, and I am really just asking for a simple code to calculate the number of days from one date to another date.
Thank you!
Copy link to clipboard
Copied
If you don't want to write the script then you can use a pre-existing one to make perform this calculation, like this script I've developed: Custom-made Adobe Scripts: Acrobat -- Calculate Time Differences in a Worksheet
Copy link to clipboard
Copied
Both Adobe and Mozilla provide free access to the JavaScript reference manuals
Acrobat JavaScript Reference Manual
Mozilla Core JavaScript Reference Manual
You need to get the values of the 2 date fields. You then convert each date string to the JavaScript date object. You can now subtract the starting date object's value form the endint date object's value. This will give you the difference in milliseconds. Now simple division by the number of milliseconds in a day will result in the difference in days.
Copy link to clipboard
Copied
These forums are for helping people with the use of their applications not doing their job or school homework.
Date and time calculations almost always require custom JavaScript coding.
This question has been asked several times. Have you used the "Search" feature to find similar post?
Use words or phrases like "number of days" or "days between".
Copy link to clipboard
Copied
I have been reading through lots of resources and can't seem to find something to help with a more complex calculation. I am new to using custom calculation scripts in Acrobat but have been successful so far with other (simpler) counts.
I want to count the number of differences between two dates that fall between a certain number of days. So my end count will be the number of times, for example, that the date range was between 0 - 30 days. I have two columns of dates: Date Recd, Date Respd. They are in mm/dd/yyyy format.
Any guidance would be greatly appreciated! Trying to cut down the amount of time I spend banging my head against a wall...
Copy link to clipboard
Copied
So you were able to calculate the difference between the two dates, and now you want to count have many of the results fall between 0 and 30, basically?
Copy link to clipboard
Copied
Yes. I was initially trying to do all of that in one field script. But I have since given up and created a column for the differences between dates. Now I just need to count how many are 0-30 days, 31-60, 61-90, etc.
Another somewhat unrelated question: how many fields can an acrobat form support generally before it starts to crash? I’m at about 500, and it’s getting really slow but I still have lots of fields to add. I was planning to se the form to people to submit, but I’m afraid others might have similar struggles with processing. Any guidance?
Copy link to clipboard
Copied
What are the names of those fields?
500 fields is a lot, but I've seen files with more than that. The issues start when you have a lot of calculated fields, as each time you change any field in the file, all of the calculations are executed. One way to control it is to use a single field for all the calculations and set up the code so that only the relevant fields get updated, based on the name of the field that was changed. This is a complex scripting task, but it's worth it in the long run. Also, I would advise disabling the fields calculations while you're editing the form and adding new fields to it.

