4 Replies Latest reply on Oct 9, 2011 1:59 AM by ajmayjnr

    Another Date Calculation Question.

    ajmayjnr

      Hi All,

       

      OK, this is a continuation from here: http://forums.adobe.com/thread/906583  Basically, I need to change the form a little and therefore need a continuation of that threads result.

       

      Short version - I need to take a future date which is calculated by taking a result of a drop down (0-13) and using this script finding a day in the futue:

      var f = this.getField("BILLINGCYCLEDATE");

      var g1 = this.getField("DAYS");

      var g = g1.value

       

      var today = new Date();

      var add = today.valueOf();

       

      add +=1000 * 60 * 60 * 24 * g;

       

      var future = new Date(add);

       

      f.value = util.printd("mm/dd/yyy", future);

       

      Basically it adds a number of days to today and giving a result.

       

      What I need to do is take that result, add another number of days (0-13 again) to give a new date.... and I am struggling to get a result at the moment.

       

      So here is a real workd scenario:

      How many days from today will the contract start?  (option 0-13 days) = RESULT A.

       

      How many days from RESULT-A will first payment be due (option 0-13) = RESULT B.

       

      Does that make sense?

       

       

      Thanks for any help you might be able to provide.

       


      Ant

        • 1. Re: Another Date Calculation Question.
          cuerdasg Level 1

          add the same script to the new field but add the following (payday is the next 0-13 field)

           

          var n1=this.getField("PAYDAY");

          var n=n1.value

           

          and change the add+ field to

           

          add+=1000*60*60*24*g*n

           

          and finally change billingcycledate field  to reference the new payday date field.

          • 2. Re: Another Date Calculation Question.
            ajmayjnr Level 1

            Hi Mate,

             

            OK, this gave me a result... but it was a result of X number of days from today (rather than from the result of "RESULT-A"

             

            Here is what I placed in as my script.

             

            var f = this.getField("DirectDebit_Start");

            var g1 = this.getField("Daysuntilstart");

            var g = g1.value

            var n1=this.getField("MembershipDaysTillBilling");

            var n=n1.value

             

            var today = new Date();

            var add = today.valueOf();

             

            add+=1000*60*60*24*g*n

             

            var future = new Date(add);

             

             

            f.value = util.printd("dd mmmm yyyy", future);

             

             

            Any thoughts on where I am going wrong?  I have tried doing a few different things but I either get no result or I get X days from today's date.

             

            Thanks for your help!

            1 person found this helpful
            • 3. Re: Another Date Calculation Question.
              cuerdasg Level 1

              Sorry its actually add+=1000*60*60*24*(g+n) ...theres 1000 miliseconds in a second, 60 seconds in a minute, 60 minutes in an hou,r 24 hours in a day, times how many days out... so the g multiplication would give you how many days untill start... and add the n for days till billing  so that the total will give you the date for the bill.  I just did the math wrong.  Hope this clears it up for you.  you could also turn g+n into a variable so that the add+ still ends in a single variable.

              • 4. Re: Another Date Calculation Question.
                ajmayjnr Level 1

                Thank you so much!  Not only did it clear it up but the explaination ensured I learnt how that calculation works - thank you mate, I truly appreciate your assistance.


                Ant