Sum time in Excel to show a big number of days - excel

I have cells with duration, specified as hours:minutes:seconds.
1726:48:00
410:10:00
599:20:00
The first line means 1726 hours, 48 minutes and 00 seconds
The second line means 410 hours, 10 minutes and 00 seconds
The third line means 599 hours, 10 minutes and 00 seconds
How do I sum these times in Excel, to get a breakdown in days, hours, minutes and seconds?

I'm afraid that might be impossible by changing the cell format.
If your number is in A1, you could use one of these 2 formulas:
=ROUNDDOWN(A1,0)&TEXT(A1," hh:mm:ss")
=INT(A1)&TEXT(A1," hh:mm:ss")
I also tried =TEXT(A1,"0")&TEXT(A1," hh:mm:ss"), but TEXT(A1,"0") sometimes does roundup which is not welcome.
The drawback of those formulas is that they return text. So you'll not be able to use the results in further calculations.

The requirement is to add a range of cells containing values called “duration”, which are expressed in Date and Time Serial Numbers and to display the result, currently formatted as [h]:mm:ss, in days, hours, minutes and seconds, (a kind of format [d] hh:mm:ss which is not allowed by the Excel application as already explained by ZygD). ZygD also proposed to use a formula to display the desired result as a text which comes with the restriction of further use in other calculations as well explained by ZygD:
=INT(A1)&TEXT(A1," hh:mm:ss")
In case that the total expressed as text needs to be expressed back as a Date and Time Serial Numbers I suggested the formula:
=SUM(LEFT(B1,-1+SEARCH(" ",B1)),
SUBSTITUTE(B1,LEFT(B1,SEARCH(" ",B1)),""))
Now if this does not satisfy the requirement there is another solution, that allows to add the Date and Time Serial Numbers showing the result as “days, hours, minutes and seconds” provided that it’s acceptable to show the result in two separated cells using the following formulas:
Values with “duration” are placed in the range C4:C6,
Totals Days in cell "C10",
Total Hours in cell "C11"
Totals Days =INT(SUM($C$4:$C$6))
Total Hours =MOD(SUM($C$4:$C$6),1)
If the totals are needed for further use just use the standard "SUM" formula to add up both, see cell C13
=SUM(C10,C11)

The "original" value can be worked backwards from ZygD's formula using the following formula:
=SUM(LEFT(B1,-1+SEARCH(" ",B1)),
SUBSTITUTE(B1,LEFT(B1,SEARCH(" ",B1)),""))

Related

Extract the hour from the h" hour(s) and "m" minute(s)" in excel

I have the list of data that showing the Hours and the Minutes that I extract from the system. I need to be extract the hours.
As example below, column B first row, the Hours would be 64 and the minutes would be 46.
But when I used the formula =Hour , its turn up the different value since its actually decimal number.
Cannot use left() , it will give the actual decimal number.
Updated:
We tried the #harun24HR 's but cannot readable the value.
But if you noticed, if i copy and paste the value is different. thats why the search not applicable.
4th Update:
To Solar Mike, I have tried the formula given from the thread the i think the value not readable
It's a time value which Excel stores as calculated value based on 24 hours = 1.
To retrieve the hours only you can use:
=INT(A2*24)
To retrieve the minutes only you can use:
=(A1-(INT(A1*24)/24))*24*60
Your time value is already a number in time format so you just need it to change it to decimal system. Dates and time values are numbers. Even if you see it as 30/09/2019 or 12:00:00, actually, for Excel, both cases are numbers.
First date Excel can recognize properly is 01/01/1900 which integer numeric value is 1. Number 2 would be 02/01/1900 and so on. Actually, today is 44659.
Now, about your data, you posted this screenshoot:
So the value is numeric, not text/string. In Excel, what you see is not always what you have. Probably that column has been formatted using custom mask. My fake data is like this:
The numeric value is 02/01/1900 16:46:36 (or 02/01/1900 4:46:36 PM it depends on your regional settings) but I've applied a custom format like this:
[hh]" hours" mm " minutes"
So what I have is a number but what I see is a text!
We have to work with the number (to be honest, ist's easier to work with numbers), so to extract the total hours, minutes and seconds.
Formula in B1: =INT(A1*24) total hours
Formula in C1: =INT(A1*24*60-B1*60) total minutes
Formula in D1: =A1*24*60*60-B1*60*60-C1*60 total seconds
This should guide you on whatever are you trying to achieve.
From your current sample data you try-
For hour =LEFT(A2,SEARCH(" ",A2)-1)
For minutes =RIGHT(SUBSTITUTE(A2," minutes",""),2)

How can I extract the hour part from a duration value in Excel?

How can I convert duration in excel to text ? I am having 1037:00:00 in a cell, which is the sum of certain durations. I want to extract 1037 alone. Excel returns "hours" when I try to extract with MID or use TEXT function.
If it is really the sum of some durations you can get the amount of hours by multiplying the cell by 24. The internal representation of a date or time cell is the number of days since beginning of the year 1900, so you have to multiply it by 24 to get the number of hours. (The year 1900 is not interesting for you as you just want a time span.) The Hour function does not work here because you get the day hour which is 5 in this case.
Be sure to format your target cell as regular number.
lets assume your cell with 1037:00:00 is in cell L40. You can use the following formula to pull the hours.
=INT(L40)*24+HOURS(L40)
Note this will only pull full hours rounded down. It does not take into account minutes or seconds.
Alternatives:
=Rounddown(L40*24,0)
This alternative is what Fratyx explained in his answer.

COUNTIFS events between dates but also time

For reporting I export raw data from a pbx in CSV. There are many columns with data. Relevant for this case is:
Column A: Date of the events (there are many events on a same day)
Column B: Length of the events in seconds
Column C: Date + Timestamp of every event
I filter out all events shorter or equal to 90 seconds,
I am able to adjust the range by changing dates in 2 cells I created for this occasion (start date is in D1 & end date is in cell D2). Without integarting time I use:
=COUNTIFS(B:B;">=90";A:A;">="&D1;A:A;"=<"&D2)
It works like a charm. I select a range in cells D1 & D2 and I automatically get all the events between these dates excluding events shorter or = to 90 sec.
On top of this I need to know how many events / occurrences happen between certain timestamps. For example from November 1st till November 7th I need to know how man events happened between 12:00h and 13:00h, how many happened between 15:00h & 18:00h etc.
Logically I thought that just adding another criteria_range and criteria (in this example column C) would do the trick. Alas adding column C does not seem to work and I have spinned it many ways.
My intuition is that the DATE + TIME format is inadequate, innapropriate for my case.
Column C looks like this: 02/11/2015 21:59:47
Being european, I'm happy with the DD/MM/YYY notation, but it seems that no formula can take account of the TIME and neglect the DATE in front. Remember I already use column A for the dates. Here in column C I am interested in the TIMESTAMP.
Any aideas or suggestions are welcome.
Thank you very much in advance.
PS: I can always split the time from the date using text to column feature. Yet It means I will be formatting the raw exports and I would like to avoid that at all costs so that I can just copy paste new exports in my control sheet without having to do all sorts of formatting.
Without sample data it is difficult to tell whether you are treating the elapsed time as 90 seconds (integer) or 00:01:30 (as true seconds, a decimal portion of 1). Your formula seems to indicate the elapsed time as an integer but it is also wrong in other places (e.g. =< instead of <=) so the only thing for certain is that it is not a working formula. The same goes for determining the time window. Are you comparing it to 12 and 13 as integers or 12:00:00 and 13:00:00 as true time? They are decidedly NOT the same thing.
The SUMPRODUCT function can provide the cyclic processing required to treat a datetime as time only (e.g. MOD(C2:C12, 1)) or as an integer representing the hour of the day (e.g. HOUR(C$2:C$12)).
  
The formulas in F2, F5 and F7 are,
=COUNTIFS(B:B; ">="&E2; A:A; ">="&E3; A:A; "<="&E4)
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(MOD(C$2:C$12; 1)>=E5)*(MOD(C$2:C$12; 1)<=E6)*(B$2:B$12>=E$2))
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(MOD(C$2:C$12; 1)>=E7)*(MOD(C$2:C$12; 1)<=E8)*(B$2:B$12>=E$2))
If E5 and E6 were 12 and 13 instead of 12:00:00 and 13:00:00 then the formula in F5 would be,
=SUMPRODUCT((A$2:A$12>=E$3)*(A$2:A$12<=E$4)*(HOUR(C$2:C$12)>=E5)*(HOUR(C$2:C$12)<=E6)*(B$2:B$12>=E$2))

Working with time DURATION, not time of day

I'm doing some benchmarking, and I want to use Excel to produce graphs of the results. I've got a simple but annoying problem which is baking my noodle.
The problem is that Excel insists that "time" means a time of day. It refuses to let me work with time durations. When I try to say "three minutes and six seconds", it misinterprets this as "three minutes and six seconds past midnight", which isn't what I meant at all.
I can work around the problem by laboriously converting everything to seconds. But then all my graphs are labelled in seconds, not minutes and seconds. Plus it's a pain to have to keep typing in =3*60+6 rather than just 3:06. And once I've done it, I have to look at the formula to check whether I entered the data correctly [and didn't screw up the formula].
Does anybody know how I can make Excel work with a time duration not anchored to a specific time of day?
You can easily do this with the normal "Time" data type - just change the format!
Excels time/date format is simply 1.0 equals 1 full day (starting on 1/1/1900). So 36 hours would be 1.5. If you change the format to [h]:mm, you'll see 36:00.
Therefore, if you want to work with durations, you can simply use subtraction, e.g.
A1: Start: 36:00 (=1.5)
A2: End: 60:00 (=2.5)
A3: Duration: =A2-A1 24:00 (=1.0)
Use format d "days" h:mm:ss or [h]:mm:ss, depending on your needs.
Say you have a duration of 30h 12m 54s:
h:mm:ss -> 6:12:54 (not correct for a duration)
[h]:mm:ss -> 30:12:54
d "days" h:mm:ss -> 1 days 6:12:54
Variations are possible: I like something like d"d" h"h" mm"m" ss"s" which formats as 1d 6h 12m 54s.
The custom format hh:mm only shows the number of hours correctly up to 23:59, after that, you get the remainder, less full days. For example, 48 hours would be displayed as 00:00, even though the underlaying value is correct.
To correctly display duration in hours and seconds (below or beyond a full day), you should use the custom format [h]:mm;# In this case, 48 hours would be displayed as 48:00.
Cheers.
With custom format of a cell you can insert a type like this: d "days", h:mm:ss, which will give you a result like 16 days, 13:56:15 in an excel-cell.
If you would like to show the duration in hours you use the following type [h]:mm:ss, which will lead to something like 397:56:15. Control check: 16 =(397 hours -13 hours)/24
I don't know how to make the chart label the axis in the format "X1 min : X2 sec", but here's another way to get durations, in the format of minutes with decimals representing seconds (.5 = 30 sec, .25 = 15 sec, etc.)
Suppose in column A you have your time data, for example in cell A1 you have 12:03:06, which your 3min 6sec data misinterpreted as 3:06 past midnight, and column B is free.
In cell B1 enter this formula: =MINUTE(A1) + SECOND(A1)/60 and hit enter/return. Grab the lower right corner of cell B2 and drag as far down as the A column goes to apply the formula to all data in col A.
Last step, be sure to highlight all of column B and set it to Number format (the application of the formula may have automatically set format to Time).
Highlight the cell(s)/column which you want as Duration, right click on the mouse to "Format Cells". Go to "Custom" and look for "h:mm" if you want to input duration in hour and minutes format. If you want to include seconds as well, click on "h:mm:ss". You can even add up the total duration after that.
Hope this helps.
The best way I found to resolve this issue was by using a combination of the above. All my cells were entered as a Custom Format to only show "HH:MM" - if I entered in "4:06" (being 4 minutes and 6 seconds) the field would show the numbers I entered correctly - but the data itself would represent HH:MM in the background.
Fortunately time is based on factors of 60 (60 seconds = 60 minutes). So 7H:15M / 60 = 7M:15S - I hope you can see where this is going. Accordingly, if I take my 4:06 and divide by 60 when working with the data (eg. to total up my total time or average time across 100 cells I would use the normal SUM or AVERAGE formulas and then divide by 60 in the formula.
Example =(SUM(A1:A5))/60. If my data was across the 5 time tracking fields was the 4:06, 3:15, 9:12, 2:54, 7:38 (representing MM:SS for us, but the data in the background is actually HH:MM) then when I work out the sum of those 5 fields are, what I want should be 27M:05S but what shows instead is 1D:03H:05M:00S. As mentioned above, 1D:3H:5M divided by 60 = 27M:5S ... which is the sum I am looking for.
Further examples of this are:
=(SUM(G:G))/60 and
=(AVERAGE(B2:B90)/60) and =MIN(C:C) (this is a direct check so no /60 needed here!).
Note that your "formula" or "calculation" fields (average, total time, etc) MUST have the custom format of MM:SS once you have divided by 60 as Excel's default thinking is in HH:MM (hence this issue). Your data fields where you are entering in your times should need to be changed from "General" or "Number" format to the custom format of HH:MM.
This process is still a little bit cumbersome to use - but it does mean that your data entry is still entered in very easy and is "correctly" displayed on screen as 4:06 (which most people would view as minutes:seconds when under a "Minutes" header). Generally there will only be a couple of fields needing to be used for formulas such as "best time", "average time", "total time" etc when tracking times and they will not usually be changed once the formula is entered so this will be a "one off" process - I use this for my call tracking sheet at work to track "average call", "total call time for day".
Let's say that you want to display the time elapsed between 5pm on Monday and 2:30pm the next day, Tuesday.
In cell A1 (for example), type in the date. In A2, the time. (If you type in 5 pm, including the space, it will display as 5:00 PM. If you want the day of the week to display as well, then in C3 (for example) enter the formula, =A1, then highlight the cell, go into the formatting dropdown menu, select Custom, and type in dddd.
Repeat all this in the row below.
Finally, say you want to display that duration in cell D2. Enter the formula, =(a2+b2)-(a1+b1). If you want this displayed as "22h 30m", select the cell, and in the formatting menu under Custom, type in h"h" m"m".
What I wound up doing was: Put time duration in by hand, e.g. 1 min, 03 sec. Simple but effective. It seems Excel overwrote everything else, even when I used the 'custom format' given in some answers.

Excel 2007: How to display mm:ss format not as a DateTime (e.g. 73:07)?

I need to create and Excel table that computes daily training times. each row has the following fields: Date, Distance, Time and Minutes/Km. My main problem is that I want to display the Time in format of mm:ss. For example: 24 min and 3 sec should be 24:03, but "Excel" turns it to 00:03:00 (3 min after midnight). I've tried setting up "special formatting" but still "Excel insists" on formatting the hours. More over, training may exceed 60 minutes and I still want it only as mm:ss
My second question is after I'm done with the formatting issue, what is the simple way to compute Time/Distance?
enter the values as 0:mm:ss and format as [m]:ss
as this is now in the mins & seconds, simple arithmetic will allow you to calculate your statistics
Excel shows 24:03 as 3 minutes when you format it as time, because 24:03 is the same as 12:03 AM (in military time).
Use General Format to Add Times
Instead of trying to format as Time, use the General Format and the following formula:
=number of minutes + (number of seconds / 60)
Ex: for 24 minutes and 3 seconds:
=24+3/60
This will give you a value of 24.05.
Do this for each time period. Let's say you enter this formula in cells A1 and A2. Then, to get the total sum of elapsed time, use this formula in cell A3:
=INT(A1+A2)+MOD(A1+A2,1)
Convert back to minutes and seconds
If you put =24+3/60 into each cell, you will have a value of 48.1 in cell A3.
Now you need to convert this back to minutes and seconds. Use the following formula in cell A4:
=MOD(A3,1)*60
This takes the decimal portion and multiples it by 60. Remember, we divided by 60 in the beginning, so to convert it back to seconds we need to multiply.
You could have also done this separately, i.e. in cell A3 use this formula:
=INT(A1+A2)
and this formula in cell A4:
=MOD(A1+A2,1)*60
Here's a screenshot showing the final formulas:
To make life easier when entering multiple dates/times it is possible to use a custom format to remove the need to enter the colon, and the leading "hour" 0. This however requires a second field for the numerical date to be stored, as the displayed date from the custom format is in base 10.
Displaying a number as a time (no need to enter colons, but no time conversion)
For displaying the times on the sheet, and for entering them without having to type the colon set the cell format to custom and use:
0/:00
Then enter your time. For example, if you wanted to enter 62:30, then you would simply type 6230 and your custom format would visually insert a colon 2 decimal points from the right.
If you only need to display the times, stop here.
Converting number to time
If you need to be able to calculate with the times, you will need to convert them from base 10 into the time format.
This can be done with the following formula (change A2 to the relevant cell reference):
=TIME(0,TRUNC(A2/100),MOD(A2,100))
=TIME starts the number to time conversion
We don't need hours, so enter 0, at the beginning of the formula, as the format is always hh,mm,ss (to display hours and minutes instead of minutes and seconds, place the 0 at the end of the formula).
For the minutes, TRUNC(A2/100), discards the rightmost 2 digits.
For the seconds, MOD(A2,100) keeps the rightmost 2 digits and discards everything to the left.
The above formula was found and adapted from this article:
PC Mag.com - Easy Date and Time Entry in Excel
Alternatively, you could skip the 0/:00 custom formatting, and just enter your time in a cell to be referenced of the edge of the visible workspace or on another sheet as you would for the custom formatting (ie: 6230 for 62:30)
Then change the display format of the cells with the formula to [m]:ss as #Sean Chessire suggested.
Here is a screen shot to show what I mean.
If you are using hand inputted data, you can enter your data as mm:ss,0 or mm:ss.0 depending on your language/region selection instead of 00:mm:ss.
You need to specify your cell format as [m]:ss if you like to see all minutes seconds format instead of hours minutes seconds format.
as text:
=CONCATENATE(TEXT(cell;"d");" days ";TEXT(cell;"t");" hours ";MID(TEXT(cell;"hh:mm:ss");4;2);" minutes ";TEXT(cell;"s");" seconds")
5.In the Format Cells box, click Custom in the Category list.
6.In the Type box, at the top of the list of formats, type [h]:mm;# and then click OK. (That’s a colon after [h], and a semicolon after mm.)
YOu can then add hours. The format will be in the Type list the next time you need it.
From MS, works well.
http://office.microsoft.com/en-us/excel-help/add-or-subtract-time-HA102809662.aspx
One convenient trick to entering elapsed times into Excel is to have two zeros and a colon before the number of minutes, details follow. For copy and paste operations into Excel without have to worry about formatting at all one can use the format 00:XX:XX where XX are two digits totaling < 60. In that case, Excel will echo 0:XX:XX in the cell contents displayed and store the data as 12:XX:XX AM. If one pastes data in a 00:XXX:XX format into Excel, or 00:XX:XX where either XX > 59 this will be converted into a fraction of a day.
For example, 00:121:12 becomes 0.0841666666666667, which if multiplied by the number of seconds in a day, 86,400, becomes 7272 s. Next, 00:21:12 would by default show 0:21:12 stored as 12:21:12 AM. Finally, 00:21:60 becomes 0.0152777777777778, also a fraction of a day.
This suggestion is made merely to avoid having to worry about specific formatting in Excel, and letting the program worry about it. Note, for Excel data internally formatted as 12:XX:XX AM one can only use certain Excel commands, for example, one can take an average. However, subtraction will only work when the result is a positive number. Such that converting times into seconds, fractions of a day, or other real number is suggested for access to more complete arithmetic operation coverage.
For example, if one has a column of mixed time formats, or times that are negative and will not display, if one changes the number formatting to General, all the times will be converted to fractions of a day.

Resources