How can I extract the hour part from a duration value in Excel? - 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.

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 do i Subtract a duration from a time in Excel?

I am having an issue with Excel and it’s probably very simple but I need to get a starting time by subtracting a duration from and end time.
For example say I know that an event needs to end at 1:55:23 pm and it will take 0:22:13 what formula would I use to find out what time I should start?
I would like to be able to input the duration in the format h:mm:ss without excel trying to turn it into a time and not a duration as well.
Thank you for any suggestions
You simply subtract them.
For example...
Cell A1 has the end time: 1:55:23 PM
Cell B1 has the duration: 0:22:13 (this is the only 'strange' part because it's actually an AM time, as in minutes after midnight... but if you think about it, that's what you want).
Cell C1 has this formula: =A1-B1
That's it.
NOTE: If your duration is longer than your event start time (for example, a 4-hour event that started at 3:00 in the morning!) then the subtraction would result in a negative time.
A negative time is OK in reality, but Excel will not display it as a formatted time... instead it displays a bunch of ############. In that case, you need to display the calculation as a decimal value, which is the fraction of a day. For example. 0.25 means exactly 6 hours. If you would prefer decimal hours you simply multiply the fractional day figure by 24.

Sum time in Excel to show a big number of days

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)),""))

Excel Subtracting periods from specific dates using 360-day calendar?

Got formulas for figuring my differences between date periods in days as follows:
=IF(F7="","0",DAYS360(F6,F7)+1)
This gives the days result for each period that I am interested in, but I then need to add each period of days together and subtract them from a current date (like doing service computation). The issue is that I need to do this second calculation within a 360-day calendar as well. If I just try to do a days360() formula with one value being the current date and the other being the total number of days that I need to backtrack, then the "original" date that it comes up with is drastically off.
This seems to be the equivalent of the difference between NETWORKDAYS and WORKDAY functions. The former counts working days between two dates, the latter adds working days to a date, you essentially want the WORKDAY equivalent for DAYS360, which I don't think exists.
You can manipulate DAYS360, though, e.g. with a date in A2 and number of days to subtract (in 360 day mode) in B2 you can use this formula for the date
=A2-B2-MATCH(B2,INDEX(DAYS360(A2-B2-ROW(INDIRECT("1:"&CEILING(B2/30,1))),A2),0),0)

Elapsed Days Hours Minutes Excluding Weekends and Holidays Time

This sounds simple but I have been pulling my hair out trying to figure out a solution. Any help before I go bald would be great.
I need a formula which is able to
calculate the duration in (days, hrs, mins) between two date\time values (eg 05/12/2012 5:30 PM and say 07/12/2012 5:45 PM);
excluding weekends and holidays.
I would like the result of the formula to read as follows "e.g 2 Days 0 Hrs and 15 Mins".
Thanks
Link to sample workbook
You can use NETWORKDAYS and NETWORKDAYS.INTL to achieve this
A bit of manipulation is required as these return net whole days:
Use these functions to calculate the number of non workdays, then subtract from the difference between start and end dates
=E3-D3-(NETWORKDAYS.INTL(D3,E3,"0000000")-NETWORKDAYS(D3,E3,$A$16:$A$24))
This returns the working day difference, where 1.0 = 1 day
NETWORKDAYS.INTL(D3,E3,"0000000") calculates whole days between the two dates (no weekends, no holidays)
NETWORKDAYS(D3,E3,"0000000",$A$16:$A$24) calculates whole working days days between the two dates (Sat/Sun weekends, holidays as per your list in $A$16:$A$24)
Difference in non-working days between the two dates.
E3-D3 is time between start and end date/times (1.0 = 1 day)
Use custom number formatting to display thye result in the format you require
d "Days" h "Hours" mm "Mins"
Note: this format won't work for negative values, you will need an alternative for when end date is before start date.
The following formula works like a treat with no additional formatting or manipulation.
To make it more stable I have turned all the holiday dates for UK 2012/13 into ‘Excel Serial Number’ format and placed them in an array bracket.
Replacing the "D5" in the formula with your cell reference for your course or metric "End Date" and "E5" with your course or Metric for "Completion Date".
=IF(E5<D5,"-"&TEXT(D5-E5,"h:mm"),NETWORKDAYS(D5,E5,({40910,41005,41008,41036,41064,41065,41148,41268,41269,41275,41362,41365,41400,41421,41512,41633,41634}))-1-(MOD(E5,1)<MOD(D5,1))&" days "&TEXT(E5-D5,"h:mm"))

Resources