6 Replies Latest reply on Nov 6, 2017 7:03 AM by scotts74312160

    How do I calculate # of months between 2 dates in Acrobat DC form?


      Hi there,


      Admitted JavaScript idiot here.  Need to calculate number of months to 2 decimals between a move in and move out date.

      I got it down to the number of days using what's below.

      To make it easy, I only need to take the result from this script and divide by 30.

      I do not need years.  So a calculation of more than 12 months is fine.

      Could someone help??


      Thank you!!


      // Custom calculate script

      (function () {



      var sStart = getField("MOVE_IN_DATE_CLIENT").valueAsString;

      var sEnd = getField("MOVE_OUT_DATE_CLIENT").valueAsString;

      var dStart, dEnd, diff;



      if(sStart && sEnd) {

      dStart = util.scand("mm/dd/yy", sStart);

      dEnd = util.scand("mm/dd/yy", sEnd);

      diff = dEnd.getTime() - dStart.getTime();

      event.value = Math.floor(diff / 864e5);

      } else {

      event.value = "";