4 Replies Latest reply on Aug 22, 2013 10:22 PM by Mornej

    Overtime Sheet (calculate number of hours)

    Mornej

      I would like to create a acrobat PDF file that calculates overtime.

      Hence I have a start time and end time field and then a field that must calculate the total overtime per line (number of hours).

      The problem I have is when I just have a normal calculation field it does not calculate correctly, for instance 17:00 start time and 18:15 end time

      That is 1.25 hours and not 1.15

       

      How do I setup a custom java script to calculate this in a pdf file?

        • 1. Re: Overtime Sheet (calculate number of hours)
          gkaiseril MVP & Adobe Community Professional

          Is the "1.15"  one hour and 15/100's or 1 hour and 15 minutes, 1:15?

           

          What script are you currently using?

           

          When you calculate the elapsed time using a given unit are them formatting back into hours and minutes, hh:MM, or just hours?

          • 2. Re: Overtime Sheet (calculate number of hours)
            Mornej Level 1

            The 1:15 is 1 hour and 15min

             

            I am currently not using a script, I cant get it to work

            I want the formatting to be H:M and not just hours, so if it is 2.75 hours (hence start time of 12:00 and end time of 14:45 then it must calculate 2.75 hours)

            • 3. Re: Overtime Sheet (calculate number of hours)
              gkaiseril MVP & Adobe Community Professional

              Then how are getting it to calculate?

               

              Date and time values are character strings because they include non-numeric values like ":" date separators and spaces. This means one needs to convert these srings to the JavaScript date object or to a number.

               

              Have you looked at the Acrobat JavaScript documentation?

               

              Date arithmetic provides one approach to the problem but does not address the custom formatting of the result. There are also a number of ways to convert just the time string to a single numeric value that does not use the date object.

               

              Unless you are very experienced in programming, I would first work out getting the elapsed time to calculate. Then tackle the formatting issue. Then I would tackle the computation of overtime. There is more than one definition of what overtime is. It can be work time of more than 8 hours in anyone day or work time over 40 hours for one week.

              • 4. Re: Overtime Sheet (calculate number of hours)
                Mornej Level 1

                Thank you for pointing me in the right direction

                I found an article that solved my problem

                 

                Morne Jordaan