3 Replies Latest reply on Dec 10, 2013 1:04 PM by philmodjunk

    Calculating Time

    bruns

      Title

      Calculating Time

      Post

           I am putting training records in a portal, I have a field for Time, should I set it up as text or time.  I tried time first but it did not play right.  Is it in minutes or should I use 1:39 as time.  I would like to record hours and minutes, I went into inspector and set up the format but it still does not do well. 

            

           I also need to count all of the time at the bottom of the portal, I assume I can use a summary field for this?

        • 1. Re: Calculating Time
          philmodjunk

               Time fields actually record time as the number of seconds from midnight to the time displayed. Whether you see minutes, hours, seconds, etc. after you exit the field is controlled by the data formatting that you specify. TimeStamp fields, on the other hand, record a date AND time by storing the number of seconds since Midnight of 12/31/0000 and both date and time formats can be specified for the field.

               In both cases, since the data is stored as a number, you can add and subtract with time and timestamp fields as long as you understand that the result will be in seconds. This means you can select a number result and show a total seconds or total hours or you can select a time or timestamp result type to show a result formatted with the typical time notation of a time field or the date and time notation of a timestamp field.

               What I can't tell from your post is what you mean by "did not play right" and thus I can't tell what exact problem you have encountered in getting this to work.

          • 2. Re: Calculating Time
            bruns

                 Thanks for replying,  I have the field formated as a time and I used the inspector to set it to show : between hours and minutes.  Do I have to manually type in the : or if I put 136 it will give me 1:36 when I exit.  That is what I thought it would do, but it is not.  If I type 136, I get 136. 

            • 3. Re: Calculating Time
              philmodjunk

                   You'll need the : to discriminate between hours and minutes. This will be the case for a time field no matter what data format you specify. The Data format controls how the data is displayed after you exit the field, not how you enter the data.

                   But it is possible to set up a field where entering 136 enters a time of 1:36 into a time field. It just isn't the built in behavior of a time field.

                   Using OnObjectValidate, you can perform a script that takes the text as entered and inserts any missing colon before the system error checking kicks in and before the data is committed. You could also enter this into a number or text field and use a calculation to enter the correct time into a different time field.