3 Replies Latest reply on Oct 2, 2017 9:22 AM by try67

    Count days between dates and error message if exceeds 180

    dhhsc84757271 Level 1

      Using Adobe Pro, I am trying to count days between two dates and if the total exceeds 180 days, I need an error message to pop up and require the user to adjust the dates until it is 180 days or less.  I have a StartDate, EndDate, and TotalDays. So far, I've been able to get the total days between two dates with a calc script:


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

      var strEnd = this.getField("EndDate").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.round(diff/oneDay);

      event.value =days;}


      What I can't figure out is how to add the additional calculation requirement to check the TotalDays field for 180 or less and have the error message .