How can I convert an integer to an elapsed time (hh:mm:ss)?

Hi folks,

Sorry to come back to you yet again with a newbie question. I have really tried hard with this one to find the answer myself from the Help etc., but I keep hitting a brick wall.

I have a database exported from Bento which includes a field for elapsed time (the “Running time” of videos & movies). Although in Bento this appears as, e.g., “1h 51m”, it has come across into Panorama as an integer (6660, = number of seconds).

I found the Help entry for the timepattern( function, and tried to enter that on the Procedure tab of my “RunningTime” field (which I had set up in formula mode). I started the procedure with RunningTime =, then tried various options for the rest, e.g.,
and even
timepattern(now(),“hh:mm:ss”) (which I cloned from the Date formula some of you helped me set up).
None of these worked.

I also changed the RunningTime field from Text to Number (Integer). But whatever I did, all that appeared was the plain number “6660”.

Can someone tell me where I’m going wrong here? And also, if possible, where I could have found that information?

Many thanks for your help!

Lets take a field “Seconds” and a text field “Duration”. Then you could enter the following (or similar) equation in the Code property of the field “Seconds”:

Duration=val(Seconds)\60+" Min. "+val(Seconds) mod 60+" Sec."

Whenever you enter a number in the Seconds field you get an automatic calculation in the Duration field.

When you have existing data in the Seconds field, you can use a similar formula with a formulafill in the Duration field:

val(Seconds)\60+" Min. "+val(Seconds) mod 60+" Sec."

Thanks, KJM. So you’re saying I can’t do this simply on the form as a way of displaying the number of seconds in the RunningTime field? I have to have it hard-coded in a new text field on the data sheet itself? Could you give me an idea of why you’d go that route?

No. I showed you a way to do it in the data sheet. — You can easily use a similar formula to display the duration in a Text Display object on a form.

Or you use both methods and simply display the Duration field on your form.

Oh, OK. Thanks. But this whole Panorama “language” is new to me, so let me see if I’ve got it right. The result I need is actually just hours and minutes—there will be no leftover seconds, because the original duration was only given in h & m. So from what you’ve said, in order to get the duration displayed as “1h 51m” I should use a procedure like this in my form (using “RunningTime” as the name of my Seconds field):

RunningTime = val(RunningTime)\60+"h "+val(RunningTime) mod 60+“s”

Or, following your original suggestion, I could rename the original “RunningTime” field on my data sheet to “Seconds”, create a new “RunningTime” field, and use the same formula to populate that with the seconds converted to "#h ##m’ format.

Does that sound right to you?

If RunningTime is your seconds field, then you do not want to overwrite the data in that field with that formula. Your formula (e.g. for a Text Display object) should consider the seconds to hours conversion:

val(RunningTime)\3600+"h "+(val(RunningTime) mod 3600)\60+“m”

It is much easier to use the timepattern( function that you mentioned first:


In your form you add a Text Display object. In the properties panel you set the mode of this object from “Literal Text” to “Formula”.
Then you enter the formula in the Formula tab:
(You would use your field name instead of mine.)

If all you want to do is convert your existing time data from their current integer seconds format to their text equivalent you can do that by changing the integer field to text and then using the Morph tool to change the current field with the timepattern( formula that Kurt suggests.


Afterwards you enter the RunningTime as simple text.

Kurt and Gary, many thanks to you both for your helpful replies. I need to have a Text Editor field on the form, not Text Display, so that I can fill in the running time on the form for new entries. So I used your morph method, Gary, to change the original field on the data sheet. (I’m not likely to need to compare running times, or sort in running-time order, so it didn’t seem necessary to retain the number of seconds.)

As I prefer the “1h 53m” format to “1:53”, I used your seconds to hours conversion, Kurt.

The result is just what I wanted. Thanks!

Just for your information, the timepattern can be written as timepattern(RunningTime,“hhh mmm”) and it will produce that format. The third h and third m are interpreted as text characters in this case.

That’s good to know, thanks Gary.