2 Replies Latest reply on Oct 16, 2014 10:20 AM by gkaiseril

    Time Card Calc.

    cookie934

      Figured this would be easy enough but i dont have enough knowledge in Java to do this.

       

      Im making a time card for my field personnel, this time card has spots for a total 6 different jobs for that day(usually its only 1 long job but sometimes its multiple small jobs. So there is 6 start times,6 end times and 6 total times,there is also a spot for lunch. What i need is a script to calculate the total time one job took, IE Job 1 Start time 7:00 End Time 8:00 = 1 hr, then a script to add up all 6 jobs, deduct the lunch time( ie 15 min, 30 min etc) and give me a total time worked for the day. Can someone help me out please?

       

      example

       

      Job 1   Start 7:00 end 8:00 total 1 hr

      Job 2   Start 11:00 end 12:00 total 1 hr

      etc

      Lunch start 9:00 end 9:30 total 30 min

       

      total: 1 hr 30 min

        • 1. Re: Time Card Calc.
          cookie934 Level 1

          Anyone?

          • 2. Re: Time Card Calc.
            gkaiseril MVP & Adobe Community Professional

            Will the day end before 23:59:59.999?

             

            Any times that bridge past midnight need additional fields and coding to account for the next day.

             

            Is lunch an elapsed time value or computed from a start and end time?

             

            This will require custom JavaScripting. The coding can be made easier by using hierarchical field names and computing the field names as needed.

             

            Basically one needs to convert the time character string to a number value. This is done either by creating a JavaScript date object and getting the time in milliseconds since the Epoch date, Midnight January 1, 1970, for the end and stating times, compute the difference in milliseconds, and then convert the difference in milliseconds into elapsed hours and minutes. Or one can split the time string into hours and minutes variables, then convert each into a common base like minutes, compute the difference and format into elapsed hours an minutes.

             

            There have been many samples posted.