Duration best practice

Questions arising from using Duration Basic Column Type with Sheets and Glide Tables:

  1. What is the format for duration literals in the Data Editor and the App?
  • I’ve tried entering 1:00:00 for one hour in the Data Editor but it appears to require decimal days as the input format (i.e. 0.04166666667).
  • I can enter a Date & Time literal into a Date & Time column in a variety of formats and Glide will interpret correctly. I don’t have to enter 1-Jan-2023 12:04 as 44927.5027777778
  • If Glide can recognise 12:40 as today at 12:40 pm (in a Date Time Column), why can’t it recognise 1:00:00 as one hour in a Duration Column?
  1. What component should be used for data entry and display of Durations?
  • If you have a table with a Row ID and a Duration, create a List Tab and enable adding records, the default Add Form generated has no UI component at all for the Duration column.
  • I have tried a Date & Time Picker but that does not work and would be clumsy for this app anyway.

Is Duration fully implemented or am I missing something? Please note that I have seen a lot of the time arithmetical solutions on the forum so if the answer is to do it that way then fine. I just want to be sure first.

Summarising what I’ve learned with thanks to @Jeff_Hager :

See also Time duration not presenting correctly in glide chart for more options and advice on data entry and interpretation options.

The duration format is really just a nicer visual representation of the decimal form. When you do date math, the result is usually a decimal number, which can be displayed as a duration using an hour:minute:second format. Just like how a date column usually contains an ISO date underneath, but can can be visually represented in a variety of different and more friendly formats.

I understand your question, but maybe my question would be, what is your use case? Sounds like you want the ability for the user to enter a duration, but how do you intend to use it afterwards? Is it usually a set number of durations (1 hour, 30 minutes, 15 minutes, etc.), or is it wide open for the user to enter any random duration they want? I think how you answer those questions could help determine the best way to have a user enter a duration and use it for anything else you may need in your app.

I’ve never used the duration column type. It’s nothing more than a numeric column with different formatting. Usually I aquire a duration from adding or subtracting two sets of dates/times.

4 Likes

The use case as you describe it is close enough. Yes, I want users to be able to enter Durations. I am happy with the generally accepted definition of duration:
[ “+” | “-” ]“:”“:”“.” (HHH:MM:SS.mmm) but generally would be happy to reduce that to just HHH:MM. The use case supports negative duration as do both Sheets and Excel.

I agree with your analysis of the representation of time and I think what you say applies equally to Data & Time. In other words Date & Time is represented differently on the machine and to the user.

Glide provides Date & Time Basic Column Type with some formatting and value interpretation sugar to allow users to enter text times and get them converted to the machine representation. So it should, of course.

However, by comparison with D&T, the support for Duration as a basic data type is lacking (IMHO) precisely because there’s is no such formatting or conversion sugar.

I believe folk have found similar issues with Duration in Glide charts.

Additionally Duration is not currently compatible with the representation of an existing Duration type column in Sheets.

Add a duration type column to Sheets and it will be initially added to Glide (automatically) as type Text:
image

Change the type of the column in Glide to Duration and the values are, as @Darren_Murphy points out below, interpreted as a decimal (or in this case whole) number and then formatted as a duration. This is incorrect:
image

This does not happen to D&T.

Thanks again for answering the questions. I’ll switch to a different solution and not use Duration.

1 Like

Summarising what I’ve learned:

  1. The format for duration literals in the Data Editor for Sheets and Glide Tables is decimal number of days. Time formats (text such as 1:00) do not work for duration.

  2. If you want to support text duration (time format) entry like Sheets and Excel you need to build a custom text entry solution. Otherwise it is decimal days in a number entry component. You can show (view not edit) duration in time format using a text field.

1 Like

For what it’s worth, I’m aware that the Duration column is something that was added as a part of AirTable support. I’m not an AirTable user, so I don’t know how AirTable handles durations, but I’d assume that the Glide implementation is compatible.

Personally, I don’t use it, for the reasons that yourself and Jeff have outlined. For most of my use cases, I need HH:MM, and as the Duration column doesn’t provide that option I just work with the Date/Time column.

Just an observation;

172800 seconds = 2 days, and 259200 seconds = 3 days.
So on face value, it would appear that Glide has taken 2 hours as 2 days, converted it to seconds, and is representing that as hours :man_shrugging:

3 Likes

That makes sense, @Darren_Murphy , thanks.

simply get the separate number entry for hours and minutes… then do the math for these and add them… and you get your duration…
1 hour = 1/24
1 minute = 1/24/60

1 Like

I get it now, thanks, I was fooled by the existence of a Duration basic type.

when you do the math… it will display as a duration… and you can add this number to any date… but I will keep these numbers separately for a better display format…
(10 hours and 5 minutes) you can create that in the template column… much nicer than the native Glide format (10:05:00)

I have a working sample here:

1 Like