3 Replies Latest reply on Sep 11, 2008 8:17 AM by (Gloria_Phillips)

    Calculating Time

      I have been struggling trying to do a simple time calculation in Adobe Acrobat 8 / LiveCycle Designer. This is my first time creating a form with a script/calculation. I was able to get a calculation to work with regular integers, but it seems like as soon as I tried using Date/Time fields the calculations failed. I've searched several forums and have found about 4 people asking the same question, but no solutions/answers.

      Basically I just have a sheet that track people working on projects. Time start to time end and was trying to get the form to calculate the hours and minutes from those two times. I tried using FormCalc with a simple formula sum(intime, -outtime) but this did not work.

      Is there a simple solution to this, or is it going to require a large amount of scripting?

      Thank you
        • 1. Re: Calculating Time
          gkaiseril MVP & Adobe Community Professional
          No. First one needs to convert the time string into some sort of numeric value so that one can perform basic arithmetic operations. And then one needs to convert the compute value back into a standard time string.

          One can use the "Time2Nm()" function to obtain the number of seconds from the Epoch date, a standard start date and time for all date and time calculations within an application. One will also need to provide the correct format for the input time string so the date or time are properly interpreted. Once one gets the number of seconds for the start and end times, one only need perform a subtraction. To get the total time one needs to add all the individual time computations to obtain the total time. Then one needs to perform a division and use the "Floor()" function to obtain the whole hours and the "Mod()" function to get the minutes less than one hour. To format the result string one uses the "Concat()" function to combine the hours the ":" and the minutes.
          • 2. Re: Calculating Time
            gkaiseril MVP & Adobe Community Professional
            Sorry, the return value is in milliseconds.
            • 3. Re: Calculating Time
              I am new to using functions in LiveCycle. I feel that I am quite competent with excel but I am a little confused by your answer. I am trying to subtract a start time from and end time using the date/time field. Have table with four columns "Day" "Start Time" "End .." "Total Time" and seven rows (Days of week). I understand what you are saying about converting the time to seconds then subtracting the end and start seconds and then converting so output is in hours and minutes. I just do not know how to set up the formula. Do I need more columns for calculations? Can I hide the calculations? Any help would be appreciated.