I have an excel sheet with the following in a row as an example:
'10:00 - 16:00'.. Typically it is HOUR - HOUR2.
I am trying to get the total hours based on this. So 10:00 - 16:00 would be 6 hours. 10:00 to 16:30 will probably be 6.5 hours etc.
Is there an possible way to do this in excel with a formula?
I'm ok with it not doing the overly complex ones (Ones with several hour - hour2 in one column) but it would make it easier if it at least did the ones that are simplistic.
Thanks!
With data in A1, in B1 enter:
=timevalue(RIGHT(A1,5))-timevalue(left(A1,5))
and then apply a time format to B1 to give hours:minutes. To get numeric hours, use:
=24*(TIMEVALUE(RIGHT(A1,5))-TIMEVALUE(LEFT(A1,5)))
You could try:
=TEXT(RIGHT(A1,(LEN(A1)-(FIND("-",A1)+1)))-LEFT(A1,(FIND("-",A1)-2)),"hh:mm:ss")
Results:
Related
I need to calculate the duration of a given event (in hours), but only taking into account the time between the hour Y and the hour X.
Example:
The event lasted from 7:00 to 14:00, but the result must be only the number of hours between 10:00 and 12:00.
Do you have any tips how to solve it?
So you need calculating the overlap of two time ranges?
Example:
Formula in G2 downwards:
=MAX(0,MIN(B2,E2)-MAX(A2,D2))
First full disclosure. Excel is new to me. My boss has given me this task. I've tried to search yadda yadda here I am. :)
I have been given the task over SETTING a NEW ETA for milk DELIVERIES. So I've taken all 700 STOPS in our region and COPY and PASTED ARRIVAL TIMES from every STOP over the LAST 50 DAYS.
I am trying to AVERAGE ETA.
Example: Truck arrives between 11:37 pm and 1:30 am over the last 50 days.
Solution:
I have 50 exact delivery times and I need an average time that falls in the 11:37 pm to 1:30 am window.
What I've tried.
AutoSum AVERAGE gives a time of 4:30 pm.
Converting all times to decimals.
Formating Custom and choosing [h]:mm:ss
The only way I seem to get a time anywhere near a valuable ETA is to change to military time and change 0:15 to 24:15, 1:15 to 25:15 etc.
While I could manually enter this in 23,000 cells there has to be an easier way.
HELP! =)
Picture of my spreadsheet
I took a shot at this. As you can see, I formatted columns B2, C2 as time hh:mm:ss AM/PM then I simply used AVERAGE formula in D2 as AVERAGE of B2 and C2
Excel seems to be doing the right thing here and I even used multiple columns
and experimented with some times.
Perhaps all that is needed is to format the cells so that the format represents as time AM/PM.
I have days as number which will give difference between two dates... For example : 01-03-2015 and 03-04-2015. I will get difference as 33 days. Now how to know this 33 days comes in which month... like 380 days comes in 13th month
I think I see what you're trying to get. How about something that just rounds the difference divided by 30?
Say your 16-07-2015 is in A1, and 30-07-2016 is in A2. In B1, =Round((A2-A1)/30,0)
If you want 31-01-2015 and 01-02-2015 to evaluate to 1 month (althought it is only one day) you could use something like =MONTH(A2)-MONTH(A1)+12*(YEAR(A2)-YEAR(A1)) where A1 and A2 are the two dates.
Otherwise something similar to Batma... I mean BruceWayne would work.
using excel 2013
I'm trying to get the total days and hours between current date/time and time stamp
using =NOW()-B3
And custom format
dd"-Days" hh"-hrs"
which gets me.
21/05/2015 12:45 00-days - 00-Hours
01/04/2015 13:23 18-days - 23-Hours
02/05/2015 13:45 18-days - 23-Hours
This is fine until a month is rolled over which will then give a wrong result. line 2 example. How do I get it to show total days.
many thanks
Use the DATEDIF function:
=DATEDIF(B3, NOW(), "d")
Unfortunately, this doesn't support hours AFAIK, so you have to combine it with your solution in order to get a combination of days and hours.
Try this... assuming your first example is written in A1:
=ROUNDDOWN(C1,0)&"-days "&TEXT(C1-ROUNDDOWN(C1,0),"hh")&"-hours"
oh yeah... use a regular number format in the cell that contains the formula.
Substract the two dates and you will have all the information you need, the integer part is the number of days, the decimal part gives you the hours.
Diff=Now()-B3
MYDAYS=Truncate(Diff)
MYHOURS=truncate((Diff-Days)*24)
Where I work I don't get paid overtime, but I accrue holiday days for the overtime I work. I have the following spreadsheet which calculates how much overtime I've done and totals it in D15.
Now I want to calculate how many days this is, based on 8 hours per day. In D16, I've done =D15/8 and formatted it as h.mm \d\a\y\s, but this shows as 2.26 days instead of 2.4375 days.
What is the correct formula to use in D16?
Note to reader: this question led to multiple solutions some of which were discussed in the comments. Here is a summary of the solution found.
First solution
=(HOUR(D15)+MINUTE(D15)/60)/8
Explanation
Dates and time in Excel are stored as serial numbers, so 19:30 is actually 0.8125.
So, if you divide it by 8, you will get 0.1015625.
This latter value is worth 2.26 days
OP's version (thanks to Danny Becket (OP)) - see the comments below.
This solution now handles hours > 24.
=((DAY(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
or better (credits to Barry Houdini):
=((INT(D20)*24)+HOUR(D20)+(MINUTE(D20)/60))/8
The former formula has a limitation for large values, perhaps not relevant here but if D20 is 800:00 then you get the wrong answer (7 days rather than 100 days). This is probably because DAY function is giving you calendar day which will "reset" at 31, best to use INT in place of DAY.
Another easily understandable version
Divide by the length of the day as a time value:
=D15/"8:00"
More easily changed if length of workday changes
Enter:
in B3 8:3
in C3 16:3
in D3 =IF(B3<C3,C3-B3-1/3,2/3-B3+C3)
Select B3:D3, format as hh:mm and copy down as far as required.
Sum ColumnD and append *3 to the formula, but format as Number.
Add data by overwriting cells in ColumnB and/or ColumnC as required (defaults do not add to total).
Copes with overtime up to next regular start time (ie including past midnight, new serial number). 1/3 because standard working day is 8 hours (24 hours is unity for date serial counter). B3 and C3 could be hard coded but (i) there is no need and (ii) allows more flexibility. If to readily identify non standard start/finish could use conditional formatting.
Does not address weekend overtime but could easily be adapted to do so (eg add column, flag weekend day with 8 in that extra column then add that 8 [1/3] to the finish time).
Make sure that D15 has a number format of [h]:mm
then have D16 as =sum(D15/"8:00") should work fine
thats what i have tracking my annual leave, I work 37h pw with a leave day being classed as 7h24m or a half day of leave as "3:42"
I have leave taken as a cumulative figure assigned as [h]:mm in cell K2 of my spreadsheet
then I have K3=SUM(K2/"7:24") for days taken formatted as a general number
you may also need to change the date datum in excel to the 1904 date system http://support.microsoft.com/kb/182247/en-gb
to get this to work (only a problem if you have negative time as I do when calculating flex hours)