0 Replies Latest reply on Mar 14, 2014 9:37 AM by tkuly

    Calculate number of working days between two date fields

    tkuly

      Hello,

       

      I'm trying to calculate the number of working days between fields date1 & date2, this code i found online helped, and it works...but i need the script to count 1 day as 1 day instead of 0.

      ex. March 3rd, 2014 to March 3rd, 2014 should count as 1 day instead of 0.

       

      I have also tried reading this http://acrobatusers.com/tutorials/date_time_part1, but there doesnt seem to be anything referring to my problem.

      Any help would be greatly appreciated! Thank you.

       

      var strStart = this.getField("date1").value;

      var strEnd = this.getField("date2").value;

      if(strStart.length && strEnd.length)

      {

        var dateStart = util.scand("mm/dd/yyyy",strStart);

        var dateEnd = util.scand("mm/dd/yyyy",strEnd);

        var diff = dateEnd.getTime() - dateStart.getTime();

        var oneDay = 24 * 60 * 60 * 1000;

        var days = Math.floor(diff/oneDay);

        event.value = days;

      }

      else

        event.value = 0;