transcript

excelisfun - Excel Magic Trick 1250: Add Times to Get Total Minutes & Seconds From Downloaded Music Data

Thumbnail of the video “excelisfun - Excel Magic Trick 1250: Add Times to Get Total Minutes & Seconds From Downloaded Music Data”
Download Markdown
Community upload. AI output has not been independently verified.

Welcome to Excel Magic Trick number 1250. If you want to download this workbook and follow along, click on the link below the video.

Hey, we've got a great video here today. We have downloaded some music data, and here's the length: 13 minutes 5 seconds, 10 minutes 55 seconds. All we want to do is add this up. If we come down here and use the keyboard shortcut for the SUM function, Alt equals, and simply highlight and hit Enter, we get 11 minutes 37 seconds. Well, that's not correct at all.

The heart of the matter here is that we need to understand time number formatting. I'm immediately going to click on the source data and use Control 1 to open the Format Cells dialog box, and sure enough, when we copied and pasted it from the internet, custom number formatting was applied: h:mm. That means our minute values are being displayed in a way that treats the first number as hours and the second as minutes. So when we see a 13, it actually means hours, and 5 actually means minutes. There's a little bit more to this, including the fact that our standard formula to add didn't add correctly.

Before we look at our solutions, let's go down here and talk about time. If I type 8:00:00, that means 8 hours, no minutes, no seconds, space, and AM. Well, it looks like that's 8 AM. But let's do a little trick here. I'm going to say equals that cell right there, Control Enter, and notice it has some custom number formatting. So I'm going to click on the drop-down and apply the General format, which wipes away the number formatting and shows us the actual number in the cell. I'm going to use the keyboard shortcut Ctrl Shift Tilde, or grave accent, and point 3 3 3 3. Yes, when you type 8 AM, Excel actually stores this as a number, and what it is, is the proportion of one 24-hour day. So when you type AM, this is what Excel does behind the scenes: it takes your 8 and divides by 24 to give you a proportion of one 24-hour day.

Similarly for military time, if I type 13:00, I'm going to Control Enter here. It looks like 13, but look up in the formula bar: 1 PM, which means 12 PM plus one extra hour. Military time is okay. If I say equals that cell right there, Control Enter, then M, and Control Shift Tilde, or grave accent, to look at what number is actually in the cell, I get 0.541666. This is what Excel did when I typed 13 in military time. It divided that hour, or hours in any combination of minutes and seconds, by 24, and sure enough, that's the actual number.

There's a second problem. If I type 13:05, like the first music time above, when I hit Enter and then try to add another song that's exactly 15 minutes, Alt Equals is incorrectly adding everything. So I'm going to redirect the dancing ants. If I add these two, I would expect 28:05. I get 4:05, which is not correct. We have to contend with the fact that we have decimals, but we also have to contend with the fact that standard time formatting doesn't show any hours past 24. If we do this in our head, 28:05 is exactly 4 hours and 5 minutes past 24.

Now let's look at custom number formatting. The custom format is hour:minute. One solution to this problem is to use custom time number formatting with square brackets. You put both the hours and the minutes in square brackets, and immediately the custom number formatting, with those square brackets, forces the display to show hours past 24. So we see 28. We still have to deal with the fact that that's actually hours and not minutes like we want, but that's a step in the right direction. When I click OK, there we go. I'll pause and add the right label here: that's the custom time number formatting to show hours past 24, using [h]:mm.

The second problem is that for some of our formulas we need minutes, not hours. How do we go from a typed time representing one hour to one minute? There are 60 minutes in an hour, so we simply divide by 60. There we get, formatted as time, 12 and 1 minutes. So that's one minute. We also need to go from minutes to seconds, so we do the same calculation: those minutes divided by 60, and now we can see this is exactly one second past midnight. In both cases we'll have to divide by 60.

Now we have all the pieces we need. We know how to convert hours to minutes and minutes to seconds. We know how to use custom number formatting, in some cases to show hours past 24. And we know exactly what a time is in the cell under our time number formatting. So now we can come up here, to 11 hours 37 seconds, and if we make that same calculation, one way to solve it is to simply add them up. Control Enter, then Control 1, come down to Custom, and use square brackets around H, with a second bracketed H, and there we go. That is definitely one way to do it. When you download this, you could just have that formula with custom number formatting. But that's still 35 hours. Let's take a look at what number is actually in the cell: Control Enter, Control Shift Tilde, 1.48. The 1 represents the 24 hours, because that's 35 hours, 37 minutes, which is 11 hours 37 minutes past the 24 hours. So the 24 is there, and the 0.48 represents the 11:37.

Now, if I really wanted to show minutes and seconds, watch this. I'm going to say equals the sum of all of these, and this would be our formula right below wherever we download this, divided by 60. Control Enter. That number formatting came from those cells, so we Control 1, come down to Custom, and simply put our [h]:mm and mm:ss. Immediately, that custom number formatting shows it's working up there. Click OK. That one's nice, because we'll be able to see whatever our total is, in hours, plus minutes, plus seconds. If we had a bunch of downloaded times that totaled more than 24 hours, we could use those square brackets.

There's still another way to deal with this. If you wanted to see 35 minutes and 37 seconds, we could again add them up, and do an even trickier custom number format. Control 1. I'm going to assume this will be less than 24 hours. Watch this: I'm going to put H H, minute minute, then space, and I don't need that colon, so I'll delete it. I'm going to type out "minutes" in double quotes, and then add seconds the same way. Custom number formatting shows anything contained in double quotes, even though those characters aren't actually in the cells. They show up on the surface of the spreadsheet as custom number formatting. Hopefully I spelled all that right, and it looks like I did. Click OK. That's not correct, though. What I really want is square brackets, because we do have hours past 24. Click OK, and there is yet another way to do it with custom number formatting.

If you actually wanted the numbers 35 and 37 themselves, we could do it this way. Say SUM and add them all up, Control Enter, Control Shift Tilde, because knowing what number is in the cell is so important. How do I get this up to hours? Excel divided by 24 when it stored the times, so we simply multiply by 24 to get back to hours. Control Enter, Control Shift Tilde. Every time I enter that, it's showing that number formatted, but we can see the 35. All I want is the 35. So I use the INT function. It always takes the integer, going down, so it takes just the 35. Close parentheses, Control Enter, and there's our 35.

I cheated a little there. Let me Control C and go into edit mode, then equals that cell, which gives us 35.61. What I really want is the decimal, and then to multiply that by 60 to get the minutes. Let me ask you a question: what is 35.61 divided by 1? It's 35 with a remainder of 0.61666, and so on. We can use the MOD function to get at that remainder. I'll hit F2, and the MOD function takes a number, which is the dividend, then a comma, then the divisor, or denominator, which is 1. Sure enough, MOD delivers that remainder, 0.616666. Now I simply F2, multiply that by 60, and when I Control Enter and Control Shift Tilde, we get our 37 minutes.

So we saw a few different solutions. We had some times for music that we downloaded, and we checked them and saw that there was a custom time format. We saw three different solutions using custom number formatting to get out the minutes and seconds. We also saw some formulas to get out exactly 35 minutes or exactly 37 seconds. All right, we'll see you in the next video.