Excel 2010 - calculating time lapsed between 2 dates & times where it is over 31 days - excel-formula

I am trying to find out the time lapsed, Days, Hours & Mins, between 2 days and times?
Date Opened: Cell J1 08/08/2012 09:00:02
Date Resolved: Cell L1 10/10/2012 07:30:00
I have tried the Following:
=INT(L1-J1) &" days "&INT(MOD(L1-J1,1)*24)&" hours " & ROUND(MOD((L1-J1)*24,1)*60,0)&" minutes"
this works and gives the lapsed time of 62 days 22 hours 30 minutes
The problem with this is that produces this as a text result meaning that I cannot Average the results automatically
I then tried:
=L1-J1
The result of this is good as it allows me to use the results and work out averages & sums
But if the lapsed time is over a month it cannot work this out - so this example gives me the incorrect result of 02:22:29 (DD:HH:MM)
What i am looking for is a formula / function that will provide me with the time lapsed in Days/ hours/ mins that correctly shows the number of days even if more than 1 month and that i am able to use the results
thanks

It is a formatting issue. The format of DD:HH:MM is treating the result as a date (2-Mar-1900 22:29)
Unfortunately I don't think there is a built in format which will give total number of days
You can get the text you want by using formula =INT(L1-J1)&":"&TEXT(L1-J1,"HH:MM")but this will be a text value rather than a numerical value

Formatting it to [h]:mm:ss would give you the number of hours. Does that help in anyway?

It seems like this is something that can't be done in one cell, but would need to be handled in 2 cells. 1 for calculating the average (and can be hidden), and one for the display you are looking for.

Related

Excel formula - Calculate Days, Hours, Minutes and seconds between 2 timestamps

I have a vba script which leaves a timestamp in cell A8 when run by the user like so:
ActiveSheet.Range("A8").Value = Format(Now(), "dd/mm/YYYY hh:mm:ss")
This displays the following in cell A8 (which is formatted as a date:
10/12/2016 9:15:10 AM
Next I want to be able to determine how many days, hours, minutes and seconds it has been since the last time the user ran the macro/vba code.
I am also capturing the current date/time by using =NOW() in cell B8.
Cell B8 is also formatted as a date and displays like so:
12/18/16 12:45
My formula should compare the timestamp in A8 with the current time and date, in cell B8.
=INT(A8-B8)&" days "&TEXT(A8-B8,"h"" hrs ""m"" mins """)
I have noted that the date formatting is not consistent here, and I don't know if this would matter?
For some reason I am not getting the desired result and I get this error with my formula:
Value!
Please can someone show me where I am going wrong?
In additions, if possible I do not want to display days, hours, minutes and seconds all at once like this:
0 days, 0 hours, 0 minutes, 0 seconds
What I actually want is if the time stamp is less than 60 seconds, to show something like:
55 seconds ago
Then something like:
20 minutes ago
then:
1 hour ago
then :
2 days ago
Thanks
First, it should be B8-A8, not the other way around, because B8 should be greater than A8. This change should make your initial formula work.
Second, your desired formula:
=IF(B8-A8>=1,INT(B8-A8)&" days ago",IF(HOUR(B8-A8)>=1,HOUR(B8-A8)&" hours ago",IF(MINUTE(B8-A8)>=1,MINUTE(B8-A8)&" minutes ago",IF(SECOND(B8-A8)>=1,SECOND(B8-A8)&" seconds ago", " just now"))))
p.s.: As per #YowE3K's comments, for this to work, your cells A8 and B8 should set to Date type, otherwise you should format them with the right format in the formulas. The first option should be easier.

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

Formula for Total hours between two date times in ms excel

I need to calculate the total hours and minutes between two dates mentioned in excel. i.e.,
Start date: 02-Sep-2013 02:03:00 AM
End Date: 04-Sep-2013 02:04:00 AM
The answer should be 48:01 h:mm.
Need to consider holidays also, like if 03-Sep-2013 is holiday, then
The answer should be 24:01 h:mm.
There are no business hours. It should consider 24 hours. Please help me on this.
a simple subtraction will get you the value you want: subtract one date/time from the other, and then subtract the number of holiday dates that fall between the two dates.
the trick is to format the result cell as [h]:mm (this format works for up to 9999 hours)
Here's an example:
Hours = ((End_Date+End_Time)-(Start_Date+Start_Time))*24
For more details please refer the below link
Excel
Another Formula with example
Cell A1: 2/15/2012 10:00:00 AM
Cell B1: 2/18/2012 08:00:00 PM
What is the elapsed time between both dates (in hours)?
You can get the answer by using the below formula in cell
C1:= INT(B1-A1)*24+(((B1-A1)-INT(B1-A1))/0.04166666)
The problem with many of the example answers given is definitional. If you are looking for elapsed time finer than days in significant digits the "B2-B1" answer given is incorrect if the end time is earlier in the day than the start time.
Depending on what I am trying to extract I use variations of the following formula to get a more precise "elapsed time". Depending on why a person lands on this answer the difference in result can make a difference.
=ROUNDDOWN(B3-B2,0) & " Days "
& ROUNDDOWN(MOD(B3-B2,1)*24,0) & " hours "
& TEXT(MOD(MOD(B3-B2,1)*24,1)*60,"#0") & " Mins"
(formatted for easier reading)
The image below shows the results of the different answers proposed. I am not saying the other answers are wrong just that they may not be precise enough depending on the purpose of the answer seeker.

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

What is wrong with this calculated field for total hours between two times in SharePoint 2007?

I am attempting to get the total hours between two times in a SharePoint 2007 list. Right now I have the formula as...
=INT(([Column2]-[Column1])*24)
...which I have looked up and says that it is the correct formula to do this. But, what I get is a weird date like "2/18/1900 12:00 AM" instead of what it should be: 26.
Another formula I tried was...
=TEXT([Column2]-[Column1],"h")
...but, this will only get the difference in hours and not count the days (if they are more than one apart).
Both of the columns are Date & Time columns. So, what am I doing wrong?
My take is that you set the output format of the calculated column to be Date and Time, while it should be of type number.
In a calculated column, the number of hours between two times is:
=TEXT([Column2]-[Column1],"h")
Providing that the difference is less than 24 hours. Otherwise, you'll need to look at getting the days difference and doing a multi-step calculation involving the number of days between the dates * 24 + the calc above.

Resources