4 Replies Latest reply on Apr 7, 2010 4:57 AM by Radio Reta

    Make a date field equal another date field

    Radio Reta

      Hello Everyone,

       

      I am converting an excel time sheet into a PDF form.  How do I make 1 date field equal to another, and then display the previous date?

      Field1  = 3/27/2010 and Field2 = 3/26/2010?  Is this possible?

       

      Any help would be greatly appreciated.

       

      Thanks,

      Shereta Fields

        • 1. Re: Make a date field equal another date field
          gkaiseril MVP & Adobe Community Professional

          Yes, you need to use JavaScript's Date object. And then use that object to make the calculations on the parts of the date.

           

           

          var sMyDateFrmt = 'mm/dd/yyyy'; // format for all dates
          var sMyDate = '3/27/2010'; // date value as a character string
          // display the start date
          app.alert('Inputted date: ' + sMyDate, 3, 0);
          var oMyDate = util.scand(sMyDateFrmt, sMyDate); // convert string date to date object
          // get the part of the date from the date object
          var nFullYear = oMyDate.getFullYear(); // get 4 digit year
          var nMonth = oMyDate.getMonth(); // get zero based month
          var nDate = oMyDate.getDate(); // get date of month
          // compute previous date 'nDate - 1'
          var oPrevDate = new Date(nFullYear, nMonth, (nDate - 1) );
          // format string for previous date
          var sPrevDate = util.printd(sMyDateFrmt, oPrevDate)
          // display previous date string
          app.alert('Previous date: ' + sPrevDate, 3, 0);

           

          1 person found this helpful
          • 2. Re: Make a date field equal another date field
            Radio_Reta

            Thanks!!!!  That was very helpful!!!!!

            I used formcalc

            SAT_DATE

            = Num2Date((Date2Num(WEEK_ENDING_DATE.formattedValue, "MM/DD/YYYY") - 0), "DD - MMM") I need to get more into Java.  

             

             

            • 3. Re: Make a date field equal another date field
              gkaiseril MVP & Adobe Community Professional

              FormCalc does not work in Acrobat Forms (AcroForm). Since this forum is for Acrobat JavaScirpt, you might want to look at using one of the LiveCycle Designer forums.

              • 4. Re: Make a date field equal another date field
                Radio Reta Level 1

                Thanks I started off in Acrobat and then ended up in LC.    I am still trying to get a grasp on the differences between the two.

                 

                Thanks for your help.