You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Logbook - sum of hours and minutes, without dates and times provided. eg (1:45 + 2:31 + 3:12 = 7:28)

Can anyone please help!


I am looking for a function to total the times provide to me by in a .txt format.


The first entry of 1:45 means 1 hour and 45 minutes.


I need to calculate 15 years worth of numbers, probably 1000+ entries, so would much prefer not to manually change each entry.

When I try to create a custom data field it always ends up changing it to 1 minute and 45 seconds.


The first 3 entries should total 7 hours and 28 minutes (6 hours and 88 minutes)


the list goes on and on!


Many thanks in advance


Posted on Sep 28, 2020 2:31 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 28, 2020 4:09 AM

You can split the the "text" times into hours and minutes and use the DURATION function to convert those into durations (segments of time) that can be be added.


Here are two ways:




If you have Numbers 10.x then you can use REGEX.EXTRACT:


=DURATION(0,0,REGEX.EXTRACT(A2,"^\d*"),REGEX.EXTRACT(A2,"\d*$"))


The regex simply says grab the first digits that are "anchored" by the ^ to the beginning of the string (the hours) and the last digits that are "anchored" to the end by the $ (the minutes).


If you have an earlier version (or you just don't like Regex) then you can use FIND:


=DURATION(0,0,LEFT(A2,FIND(":",A2)−1),RIGHT(A2,LEN(A2)−FIND(":",A2)))


Place whichever formula you want to use in an adjacent column and change A2 to the first value of your list of "times". Then fill or copy paste down the column. Then, with the whole column selected, "remove" the formula by command-c followed by Edit > Paste Formula Results.


You can change the Duration formatting via the 'Style' dropdown in the right panel as shown in the screenshot.


If your region uses , as a decimal separator be sure to substitute ; for , in the formula.


More on the DURATION formula here.


SG


Similar questions

5 replies
Question marked as Top-ranking reply

Sep 28, 2020 4:09 AM in response to cjerv

You can split the the "text" times into hours and minutes and use the DURATION function to convert those into durations (segments of time) that can be be added.


Here are two ways:




If you have Numbers 10.x then you can use REGEX.EXTRACT:


=DURATION(0,0,REGEX.EXTRACT(A2,"^\d*"),REGEX.EXTRACT(A2,"\d*$"))


The regex simply says grab the first digits that are "anchored" by the ^ to the beginning of the string (the hours) and the last digits that are "anchored" to the end by the $ (the minutes).


If you have an earlier version (or you just don't like Regex) then you can use FIND:


=DURATION(0,0,LEFT(A2,FIND(":",A2)−1),RIGHT(A2,LEN(A2)−FIND(":",A2)))


Place whichever formula you want to use in an adjacent column and change A2 to the first value of your list of "times". Then fill or copy paste down the column. Then, with the whole column selected, "remove" the formula by command-c followed by Edit > Paste Formula Results.


You can change the Duration formatting via the 'Style' dropdown in the right panel as shown in the screenshot.


If your region uses , as a decimal separator be sure to substitute ; for , in the formula.


More on the DURATION formula here.


SG


Logbook - sum of hours and minutes, without dates and times provided. eg (1:45 + 2:31 + 3:12 = 7:28)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.