3 Replies Latest reply on May 24, 2016 7:14 AM by Carstano

    Calculating Dates

    Carstano

      I need to calculate a new date based off another date and exclude weekends.

       

      For example I have a field called "Date Position Closed". If I enter a date of 5/20/2016 it should populate another field called "Target Date QRB" with 9/27/2016. Which is 90 business days after the initial date.

       

      So far this is what I have, but it calculates based off all calendar days:

       

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

      if(strStart.length)

      {

        var DatePositionClosed = util.scand("m/dd/yyyy",strStart);

        var oneDay = 24 * 60 * 60 * 1000;

        var dueMillis = DatePositionClosed.getTime() + 130 * oneDay;

        var dueDate = new Date(dueMillis);

        event.value = util.printd("m/dd/yyyy",dueDate);

      }

      else

        event.value = "NA";