6 Replies Latest reply on May 2, 2016 3:30 AM by danielfarnan

    Elapsed Time Calculation

    lynfordd@mac.com

      My Calculation

      (EndTime-StartTime) /3600

       

      My Three Fields

      EndTime

      StartTime

      TotalTime

      It seams to work fin on Hole Hr Calculations but never with additional minutes.

      if i divide by seconds in day it never works correct 86400

      but using seconds in a HR i get the correct answer.

       

      Simply trying to calculate time between start and stop time always on same day?

      Thank you for your help.

        • 1. Re: Elapsed Time Calculation
          siplus

          first script line

           

          Set Variable [$start; Get ( CurrentTimeUTCMilliseconds )]

           

          last script line

           

          Set Variable [$$Stop; Get ( CurrentTimeUTCMilliseconds ) - $start]

           

          put $$stop as merge field on a layout; if you want seconds or other units instead of ms divide $$stop accordingly on last line.

          1 of 1 people found this helpful
          • 2. Re: Elapsed Time Calculation
            bigtom

            siplus is correct. No matter how you are doing it in your calc, using Get ( CurrentTimeUTCMilliseconds ) for the fields is the better way.

            1 of 1 people found this helpful
            • 3. Re: Elapsed Time Calculation
              lynfordd@mac.com

              $start; Get ( CurrentTimeUTCMilliseconds

              (EndTime-StartTime) /3600

              $$Stop; Get ( CurrentTimeUTCMilliseconds ) - $start

              ?

              Im entering the time in the field

              seam to not get that to work?

              Thank you for your help

              • 4. Re: Elapsed Time Calculation
                bigtom

                What function are you currently using to set the time in the field?

                Get(CurrentTimestamp)? Get(CurrentTime)?

                • 5. Re: Elapsed Time Calculation
                  bigtom

                  Have you tried GetAsNumber(Get(CurrentTimestamp))?

                  • 6. Re: Elapsed Time Calculation
                    danielfarnan

                    The issue here is that siplus described the solution for a script and you seem to want the result automatically calculated by a field.

                     

                    While siplus and bigtom are correct that Get ( CurrentTimeUTCMilliseconds) is the most accurate and reliable way to get the answer, I suspect that your StartTime and EndTime fields are TIME fields and not NUMBER fields. FileMaker stores a TIME as the number of seconds since midnight on a particular day; if you are never going to cross the midnight boundary then your calculation should indeed be ( EndTime - StartTime ) / 3600.

                     

                    I suspect that what you actually want is a calculation field that has a result type of TIME (rather than the default NUMBER) - this will automatically show you the difference between the two values expressed in hours, minutes and seconds.

                    Screen Shot 2016-05-02 at 8.28.19 PM.png

                    1 of 1 people found this helpful