Help

How to convert duration field into into a HH:mm:ss text field?

Solved
Jump to Solution
3015 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Carl_Labanz
5 - Automation Enthusiast
5 - Automation Enthusiast

This seems like something I should have been able to figure out, but I've been struggling to come up with a solution. 

Duration fields are handy for inputting data, displaying data, and manipulating it in Airtable. But the underlying data is the number of seconds in a text string. For example, one hour, seven minutes, and seven seconds will show as 1:07:07 but the underlying data is "4027". 

When I use the output via automation, the field output is 4027. I want to use 1:07:07. 

Does anyone know a formula or automation that I can set up to convert seconds into a HH:mm:ss text output?

2 Solutions

Accepted Solutions
John_B2
6 - Interface Innovator
6 - Interface Innovator

See if this clears it up. ("test" is the duration field).

IF(test, 
  CONCATENATE(
    INT(test/3600), " hours " ,
    INT(MOD(test,3600)/60)," minutes ",
    MOD((test-3600),60), " seconds " ),
  "") 

See Solution in Thread

Carl_Labanz
5 - Automation Enthusiast
5 - Automation Enthusiast

I made another edit so that it can work with a duration of longer than an hour and less than an hour. For example, you will get 1:30:00 for an hour and a half, but only 30:00 for a half hour. You also don't need the -3600 in the last couple of sections. 

 

 

IF({Video Length}>3600,
CONCATENATE(
    INT({Video Length}/3600),
    IF(INT(MOD({Video Length},3600)/60)<10,":0",":"),
    INT(MOD({Video Length},3600)/60),
    IF( MOD(({Video Length}),60)<10,":0",":"),
    MOD(({Video Length}),60) ),
CONCATENATE(
    INT(MOD({Video Length},3600)/60),
    IF(MOD(({Video Length}),60)<10,":0",":"),
    MOD(({Video Length}),60)
    )
)

 

See Solution in Thread

3 Replies 3
John_B2
6 - Interface Innovator
6 - Interface Innovator

See if this clears it up. ("test" is the duration field).

IF(test, 
  CONCATENATE(
    INT(test/3600), " hours " ,
    INT(MOD(test,3600)/60)," minutes ",
    MOD((test-3600),60), " seconds " ),
  "") 

Thank you, I haven't worked with MOD before. I see how that works and will need to work with it some more so that I think of it next time. I made a bit of a change just to keep the 0:00:00 format.

 
CONCATENATE(
INT({Total Video Length}/3600),
IF(INT(MOD({Total Video Length},3600)/60)<10,":0",":"),
INT(MOD({Total Video Length},3600)/60),
IF( MOD(({Total Video Length}-3600),60)<10,":0",":"),
MOD(({Total Video Length}-3600),60) )
Carl_Labanz
5 - Automation Enthusiast
5 - Automation Enthusiast

I made another edit so that it can work with a duration of longer than an hour and less than an hour. For example, you will get 1:30:00 for an hour and a half, but only 30:00 for a half hour. You also don't need the -3600 in the last couple of sections. 

 

 

IF({Video Length}>3600,
CONCATENATE(
    INT({Video Length}/3600),
    IF(INT(MOD({Video Length},3600)/60)<10,":0",":"),
    INT(MOD({Video Length},3600)/60),
    IF( MOD(({Video Length}),60)<10,":0",":"),
    MOD(({Video Length}),60) ),
CONCATENATE(
    INT(MOD({Video Length},3600)/60),
    IF(MOD(({Video Length}),60)<10,":0",":"),
    MOD(({Video Length}),60)
    )
)