Duration fields are awesomely useful. However, if one wants to simply transfer the displayed duration (e.g. 1:45) to another field via a formula, Airtable passes along the stored value in seconds. Converting that back into a duration-like display is doable, but a little tricky, as I found out in this recent discussion:
I tried the TIMESTR() function, but that just gave an error, so I ended up writing my own seconds-to-duration formula.
My suggestion: expand the TIMESTR() functionโs capabilities to also convert durations into strings. I suppose a new function named something like DURSTR() might also work, but because durations are all about time, wrapping that conversion into TIMESTR() feels like it makes more sense.
Good job on the formula. Looking back at when I wrote the initial post, that mustโve been really really close to when I first started using Airtable. Nowadays Iโd do pretty much what you wrote. :slightly_smiling_face:
Welcome to the community, @Zack_McCarty! :grinning_face_with_big_eyes: I tried your formula as well as the one above, and they output exactly the same thing. Hereโs the comparison, with yours in the middle, and the one from @Artem_Bourov on the right.
On the left is one that I wrote a couple months ago (after completely forgetting about this thread), which uses the following formula (my duration field is named โTimeโ):
when I used the formula at the top, the Mod formulas were showing many decimals, so I simply added the round formulas to ensure that there were no extra decimals showing.
Apologies if that came across negatively! Maybe this was something specific to my machine.
Thanks for the clarification. Duration fields can store fractions of seconds internally, and that might show up in the final formatted version depending on the source of your duration data. However, the duration fieldโs formatting defaults to rounding the display to whole values. For me (and Iโm guessing for @Artem_Bourov as well), the duration will never be fractional, so we never hit that issue when building the final string version, and the shorter formulas are sufficient. It sounds like your duration data often contains fractional values, so that longer formula makes more sense. My gut says that thereโs probably a way to make it more compact, but I donโt have time at the moment to look for possible ways to optimize it.
Thanks for the formulas! I needed to convert a duration to a 12 hour AM/PM format with seconds added. Example: duration of zero produces โ12:00:00 AMโ. Hereโs my formula based on the earlier topics in this conversation:
This works by taking advantage of the fact that the time portion of TODAY() is always going to be midnight. Add the hours to that time, then add the minutes, then format it.