Adding time durations as actual numbers

dchouston
dchouston ✭✭
edited 12/09/19 inFormulas and Functions

Hello,

We're trying to use Smartsheet to report on music details. It would be very useful to take the durations of music tracks (formatted either as mm:ss or h:mm:ss) and add them together together for a total duration. How would we attempt this?

Smartsheet sample.PNG

Comments

  • If you locate successive tracks as children tasks connected to each other by a FS link (Finish-Start, i.e. the standard link between tasks)

    Then position a parent task on top of these → the parent will sum up the all sequence automatically.

    Alternatively, you can use "+" or "=SUM(...)"

    (Sorry I might have missed something because my answer looks too obvious. Do not hesitate to address more constraints if any)

    Respectfully yours,

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    Unfortunately Smartsheet is not capable of calculating time as far as hours/minutes/seconds go. There are a few workarounds out there in some other threads, but they are all rather tedious and complex.

  • J. Craig Williams
    J. Craig Williams ✭✭✭✭✭✭

    Since your data is formatted like this

    [HHH]H:MM:SS

    (assuming hours could be more than 9)

    this formula will give you thesecondsof a single cell:

    =VALUE(LEFT(TL@row, FIND(":", TL@row) - 1)) * 3600 + VALUE(MID(TL@row, FIND(":", TL@row) + 1, 2)) * 60 + VALUE(RIGHT(TL@row, 2))

    (My column name is TL)

    I would add a column to house this and then sum that column.

    Craig

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    "I would add a column to house this"

    We can call this column "Seconds".

    "and then sum that column."

    If you put the following formula into a column other than the Seconds column (top row of the TL column in Craig's example is what I suggest), Then it will sum all of the rows in the Seconds column and convert it back to HH:MM:SS.

    =INT(SUM(Seconds:Seconds) / 3600) + ":" + IF(INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60) < 10, "0" + INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60), INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60)) + ":" + IF((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600) * 3600) + VALUE(INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60) * 60))) < 10, "0" + (SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600) * 3600) + VALUE(INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60) * 60))), (SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600) * 3600) + VALUE(INT((SUM(Seconds:Seconds) - (VALUE(INT(SUM(Seconds:Seconds) / 3600)) * 3600)) / 60) * 60))))

    If you're looking to use parent rows to show a total of each child row, you would replace Seconds:Seconds with CHILDREN(Seconds@row).

  • J. Craig Williams
    J. Craig Williams ✭✭✭✭✭✭

    Here's a shorter version:

    =INT(Sec@row / 3600) + ":" + IF(INT((Sec@row - INT(Sec@row / 3600) * 3600)) < 600, "0") + INT((Sec@row - INT(Sec@row / 3600) * 3600) / 60) + ":" + IF(Sec@row - (INT(Sec@row / 3600) * 3600) - (INT((Sec@row - INT(Sec@row / 3600) * 3600) / 60) * 60) < 10, "0") + (Sec@row - (INT(Sec@row / 3600) * 3600) - (INT((Sec@row - INT(Sec@row / 3600) * 3600) / 60) * 60))

    I assume the Sec@row is the summed value.

    Why this is shorter:

    Instead of doing this:

    IF (a very long formula is less than 10, "0" + a very long formula, a very long formula)

    I do this:

    IF (a very long formula is less than 10, "0") + a very long formula

    Craig

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    I assume theSec@rowis the summed value.

    In my formula, I used the column you put YOUR formula in and called it "Seconds" since it would convert HH:MM:SS into seconds by row.

    With your single conversion column going by row, there wasn't a SUM yet. That's why I used Seconds:Seconds. To sum up all of the cells in your conversion column AND convert it back to HH:MM:SS all at the same time.

    I do this:

    IF (a very long formula is less than 10, "0") + a very long formula

    That's definitely a good idea. It saves on space, and depending on the length of the overall formula, is less likely to exceed the 4,000 characters/cell limit.

    I would just copy/paste the "very long formula" to avoid typos. Since it isn't very many keystrokes doing it that way, I didn't even think about doing it your way. Definitely going to try to keep it in mind though.

  • J. Craig Williams
    J. Craig Williams ✭✭✭✭✭✭

    "Copy / Paste is the work of the Devil" - Craig Williams

    Theoretically

    A = SUM(a bunch of stuff)

    B = use A a bunch of times

    is faster than

    B = SUM(a bunch of stuff) a bunch of times.

    My personal character limit on formulas is something less than 500. If it is longer than 100, I reevaluate to see what I'm missing.

    Craig

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    devilI love copy/paste when I know something is working. I have fat fingers.

    And I see what you're doing. You're going ahead and summing up all of the seconds SUM(Seconds:Seconds) and THEN converting it back to HH:MM:SS.

    Even breaking it down into 2 separate steps, it's still shorter and only one more extra cell used. This is why I typically defer to you, the Smartsheet Yoda. HAHA!

    dchouston: Craig has the best solution (so far). Only look at my posts if you want to learn from my mistakes. Otherwise... You can ignore them.

  • J. Craig Williams
    J. Craig Williams ✭✭✭✭✭✭
    edited 08/16/18

    Your answers aren't mistakes. They get the job done. In this case, one is it working, it is unlikely it will be changed - does anyone need to see DD:HH:MM:SS?

    But ...

    “简单比复杂。复杂的是更好的than complicated." - Tim Peters

    Glad I am willing to listen to my advice you are.

    I'm going to post the back story on Copy / Paste to my website.

    Craig

  • Thanks all...Smartsheet really makes you work for it, don't they!

    I've got it all working. Now let's see if I can explain it to radio hosts...

    Cheers,
    David
  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the公式手册模板!
In this case you would change it to:<\/p>

=IF([1.Question]@row = \"C\",1,0)<\/p>

The [ ] brackets go around your column name that's being referenced.<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[]},{"discussionID":111402,"type":"question","name":"Trying to find total spent by month","excerpt":"I am trying to find a formula for my calculations sheet to show how much was spent during each month. Below is a snippet of the Maintenance Tracking Sheet that my team uses to track each invoice (this will be the reference sheet). I have tried numerous formulas and none have worked. For example, how much was spent if the…","snippet":"I am trying to find a formula for my calculations sheet to show how much was spent during each month. Below is a snippet of the Maintenance Tracking Sheet that my team uses to…","categoryID":322,"dateInserted":"2023-10-09T15:59:41+00:00","dateUpdated":null,"dateLastComment":"2023-10-09T19:22:40+00:00","insertUserID":167505,"insertUser":{"userID":167505,"name":"Bhawkins","title":"Project Coordinator","url":"https:\/\/community.smartsheet.com\/profile\/Bhawkins","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-10-09T20:51:49+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":45516,"lastUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-10-09T19:31:56+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":28,"score":null,"hot":3393748341,"url":"https:\/\/community.smartsheet.com\/discussion\/111402\/trying-to-find-total-spent-by-month","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/111402\/trying-to-find-total-spent-by-month","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":111402,"commentID":399192,"name":"Re: Trying to find total spent by month","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/399192#Comment_399192","dateInserted":"2023-10-09T19:22:40+00:00","insertUserID":45516,"insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-10-09T19:31:56+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"image":{"url":"https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png","urlSrcSet":{"10":"https:\/\/us.v-cdn.net\/cdn-cgi\/image\/fit=scale-down,width=10\/https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png","300":"https:\/\/us.v-cdn.net\/cdn-cgi\/image\/fit=scale-down,width=300\/https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png","800":"https:\/\/us.v-cdn.net\/cdn-cgi\/image\/fit=scale-down,width=800\/https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png","1200":"https:\/\/us.v-cdn.net\/cdn-cgi\/image\/fit=scale-down,width=1200\/https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png","1600":"https:\/\/us.v-cdn.net\/cdn-cgi\/image\/fit=scale-down,width=1600\/https:\/\/us.v-cdn.net\/6031209\/uploads\/OA7P9C9OF9RY\/capture-png.png"},"alt":"Capture.PNG"},"attributes":{"question":{"status":"accepted","dateAccepted":"2023-10-09T18:19:32+00:00","dateAnswered":"2023-10-09T17:19:09+00:00","acceptedAnswers":[{"commentID":399163,"body":"

Try something along the lines of<\/p>

=SUMIFS({$$ Range}, {Date Range}, AND(IFERROR(MONTH(@cell), 0) = 5, IFERROR(YEAR(@cell), 0) = 2023))<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]},{"discussionID":111395,"type":"question","name":"Rounding Formula","excerpt":"Hi, I'd like to round the result of the division in this formula to the nearest whole number. =IF([Column1]@row = \"Text1\", [Column2]@row, IF([Column2]@row = \"n\/a\", \"n\/a\", [Column2]@row \/ 2)) I tried placing MROUNDright before the last section of the formula like this, but I got the error \"INCORRECT\" =IF([Column1]@row =…","snippet":"Hi, I'd like to round the result of the division in this formula to the nearest whole number. =IF([Column1]@row = \"Text1\", [Column2]@row, IF([Column2]@row = \"n\/a\", \"n\/a\",…","categoryID":322,"dateInserted":"2023-10-09T13:52:58+00:00","dateUpdated":null,"dateLastComment":"2023-10-09T17:09:39+00:00","insertUserID":140693,"insertUser":{"userID":140693,"name":"User251","title":"","url":"https:\/\/community.smartsheet.com\/profile\/User251","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-10-09T15:52:46+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":45516,"lastUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-10-09T19:31:56+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":3,"countViews":25,"score":null,"hot":3393732757,"url":"https:\/\/community.smartsheet.com\/discussion\/111395\/rounding-formula","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/111395\/rounding-formula","format":"Rich","tagIDs":[254],"lastPost":{"discussionID":111395,"commentID":399159,"name":"Re: Rounding Formula","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/399159#Comment_399159","dateInserted":"2023-10-09T17:09:39+00:00","insertUserID":45516,"insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-10-09T19:31:56+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-10-09T15:56:26+00:00","dateAnswered":"2023-10-09T13:58:03+00:00","acceptedAnswers":[{"commentID":399131,"body":"

You need an opening parenthesis after the function.<\/p>

MROUND([C<\/strong>olumn2]@row \/ 2),2)<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":322,"name":"Formulas and Functions","url":"https:\/\/community.smartsheet.com\/categories\/formulas-and-functions","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":254,"urlcode":"formulas","name":"Formulas"}]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=322&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":10000,"limit":3},"title":"Trending in Formulas and Functions ","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in Formulas and Functions