Skip to main content
Participating Frequently
October 15, 2025
Question

Calculate total number of days a vehicle is driven based on dates

  • October 15, 2025
  • 2 replies
  • 380 views

In an Adobe form I am trying to calculate the number of days a vehicle is driven based on dates entered on multiple lines of the form. Vehicles may make multiple trips on one day, but only one day should be counted, not the number of trips. One trip may be made up of multiple days, so all days should be counted. This example should add up to 13 days driven. The form fields are named LeaveRow1 through LeaveRow20, and ReturnRow1 through ReturnRow20. The calculated field is DaysDriven. Can anyone provide the custom calculation script to make this work?

 

Leave DateReturn Date
10/110/1
10/210/2
10/310/8
10/910/9
10/910/10
10/1010/13

2 replies

PDF Automation Station
Community Expert
Community Expert
October 15, 2025

For date calculations your dates should include the year as well.

Thom Parker
Community Expert
Community Expert
October 15, 2025

More is needed than finding the interval between dates. There needs to be a technique for determining the inclusive dates. Then counting those days.  One method would be to use an array where every element is a day in the range.  A true value indicates the car was used on that day.   There are probably other ways to do this. 

 

  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
October 15, 2025

Thanks, Thom, but I was hoping someone could provide the actual javascript that I could enter in the Calculations tab of the field.

Thom Parker
Community Expert
Community Expert
October 15, 2025

Ok, so you are not interested in learning Acrobat JavaScript?  Or doing any development yourself?  How much time do you think this someone would spend developing and testing this code?  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often