1 Reply Latest reply on Nov 24, 2014 1:27 PM by try67

    Date + 1 and return only the day of the month

    Rich_Slack

      I have to populate a form with the days of the month.  I have a date field where the end user will enter the date when we are supposed to start recording data on the form. Accross the top of the form will be 30 fields with 30 dates (days only) in them.  For instance, if the form started on 11/24/2014 then the first field would  be: "24", "25", "26", "27", "28", "29", "30", "1", "2", etc. . for 30 days. 

       

      So I am looking for a formula that will take the date entered in the "StartDate" field and allow me to add a number of days to it. (the first field in the column would be + 0, the second field in the column would be +1, the third field in the columns would be +2 etc. through 30 days.).  And then the trick would be once we took the StartDate+1 we just returned the days portion of the mm/dd/yyyy. 

       

      Can anyone help me out please.  My assumption is that if I get the single formula I can just paste it into all the fields in the columns and then adjust the + X variable.

       

      Thank you in advance for your help!

        • 1. Re: Date + 1 and return only the day of the month
          try67 MVP & Adobe Community Professional

          Here's the code for the calculation script of the +1 field. Should be pretty straight-forward to adjust it for the rest. I would recommend putting it in a function, though, and passing the number of days to increment as a parameter:

           

          event.value = "";
          var startingDate = this.getField("StartingDate").valueAsString;
          if (startingDate!="") {
              var d = util.scand("mm/dd/yyyy", startingDate);
              d.setDate(d.getDate()+1);
              event.value = d.getDate();
          }