# In need of duration (MM:SS) to do calculations

I have a table of songs and their durations. How can i display this as MM:SS and then summarize those durations to show as a summary of how long a “playlist” is.

I’ve done this before but don’t remember the exact formulas. So I am cheating a bit here by letting ChatGPT answer (with some edits…)

———

In Grist, you can use column-wide Python formulas to compute on your data. If you have durations in MM:SS format in Grist and want to sum them, here’s a method leveraging Grist’s Python capabilities:

1. Convert MM:SS to Seconds:

1. Suppose your durations are in a column named `Duration`.
2. Create a new column, say `Seconds`. Set its formula to:
``````minutes, seconds = map(int, \$Duration.split(":"))
return minutes * 60 + seconds
``````
2. Sum the Seconds:

• Add a summary table to get the sum of `Seconds` column (total, or grouped by something).
3. Convert the Sum Back to MM:SS Format:

1. Create another column, say `TotalDuration`, at the position where you want to display the total duration in MM:SS.
2. Set its formula (for the cell where you want the total) to:
``````total_seconds = \$Seconds
return f"{total_seconds // 60}:{total_seconds % 60:02}"
``````

Awesome thanks so much, after using that i was able to use AI to get my total per playlist. very cool.

Thanks.