5 Replies Latest reply on Mar 4, 2013 9:39 AM by Mandy_Wiesener

    Calculate DateTimeField

    Miss Caroline Level 1

      How do you add days to a date field using JavaScript in LiveCycle Designer ES2? I have a field named DTFBeg that is a user-input field. I'd like to take this value, add 7 days to it, and display the new value in the field called DTFThru. Both the fields are on the Master Page of a flowable form. I've tried so many different JavaScript options from different samples I've found online, but nothing I've tried pulls a value anywhere close to what I'm looking for.

       

      Thanks in advance to anyone who can help!

       

      Caroline

        • 1. Re: Calculate DateTimeField
          Mandy_Wiesener Level 3

          Hi Caroline,

           

          you have to use this script in the exit-event from the user input-date-field.

           

          if(this.rawValue != null)

          {

              var sDate = util.scand("yyyy-mm-dd", this.rawValue);

              //THE SEVEN IN THE END OF THE LINE YOU CAN CHANGE WHEN YOU WISH TO ADD MORE OR LESS DAYS

              var NewsDate = Number(sDate) + (24*60*60*1000*7);

              var nDate = util.printd("dd.mm.yyyy", new Date(NewsDate));

             //DatumsUhrzeitfeld2 --> YOUR TARGET FIELD --> PLEASE CHANGE THE NAME IN YOURS

              DatumsUhrzeitfeld2.rawValue = nDate;

          }

           

          I hope it's helpfull for you?

          Kind regards

          Mandy

          • 2. Re: Calculate DateTimeField
            Miss Caroline Level 1

            Thank you SO much, Mandy. I've been teaching myself the JavaScripting and can usually figure things out myself, but I would have never come up with this! I do appreciate your help immensely!

             

            I do have one slight problem that hopefully you can help me with. I put the date fields on my Master Page with the thought that they would display on all pages, but the fields are only populating on the first page. I've looked at the properties on both fields to see if there was something to do with pagination, but don't see anything that's causing them to reset. Any ideas?

            • 3. Re: Calculate DateTimeField
              Mandy_Wiesener Level 3

              Hi Caroline,

               

              I'm happy that's work.

               

              For the next question I think it's better to open a new discussion? Then another user can find the solution because the new discussion have another significant title.

               

              I will answer soon.

               

              Kind regards,

              Mandy

              • 4. Re: Calculate DateTimeField
                Miss Caroline Level 1

                Okay. Thank you!

                1 person found this helpful
                • 5. Re: Calculate DateTimeField
                  Mandy_Wiesener Level 3

                  I have seen the new discussion