1 Reply Latest reply on Feb 24, 2017 8:32 AM by try67

    Acrobat Pro DC - Date fill and calculation

    Isaiah25

      Using Adobe Acrobat Pro DC...

      I have created a PDF Form which includes a field for the current date, "Today".  It seems to work.  I used the following in the "Custom Calculation Script" section

       

      var f = this.getField("Today");

      if (f.value == "") f.value = util.printd("mm/dd/yyyy", new Date());

       

      I have a fillable field for a project beginning date "OnAssignment".

       

      Assuming both those fields  (Today and OnAssignment)  are populated...    I want a third field, "Duration"  to then calculate and display the current duration - the difference between "Today" and "OnAssignment", and have no idea how to do that.  The obvious secondary question would be how best to format the result in the "Duration" field.  I am hoping for...   (example)...    2.3 Years

       

      Any assistance, guidance, reference, resource, and/or education would be greatly appreciated.

        • 1. Re: Acrobat Pro DC - Date fill and calculation
          try67 MVP & Adobe Community Professional

          You would need to convert both strings to Date objects (using the scand method of the util object), deduct them from one another and then divide the results by the number of ms per year... You might also need to make sure that the value is not negative, ie that the OnAssignment date is actually after the Today date.