Get total days and Hours between 2 timestamps with excel - excel

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)

Related

Date Arithmetic Microsoft excel

I'm trying to subtract Column B from Column A in excel to find out how many hours have passed between these two times but so far no luck.
Column A | Column B
05/01/11 11:54 | 05/01/11 08:46
I appreciate your help
Tried all the TIME related functions and did lots of research online but nothing.
The following formula should do what you want:
INT(A2-B2)&" days "&TEXT(A2-B2,"h"" hrs ""m"" mins """)
You can use the hour function
Hour(B1-A1)
which gives 3
Here is a link to another solution: https://stackoverflow.com/a/2324935/4293532
Note: Make sure that your data are formatted as dates, they are generally aligned to the right.
If you want it in hours rather than days and hours
=(A1-B1)*24
(which can be rounded down if you want whole hours)

How to calculate the hour between two hour times in Excel?

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:

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

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.

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.

Basic excel date and time problem

Have a list of dates in excel in the format (this comes originally from csv):
23/11/09 07:27:02
23/11/09 08:01:50
23/11/09 08:38:58
23/11/09 09:40:01
What I want to do is count the number of these falling between hour blocks, like 7-8, 8-9, 9-10 etc
Not sure how to get started, but one idea was just to put logic statements comparing the dates between these blocks, then adding the total "trues"
I can't get it to compare properly. When I type it the hour block marks,
e.g. 23/11/09 08:00
excel actually shows that as
23/11/2009 8:00:00 AM
and the compare doesn't work. Well actually it does the opposite of what it should.
that is:
=IF(C5>L1,IF(C5<M1,TRUE,FALSE),FALSE)
C5 being date in top codeblock, L1 and M1 being the hour blocks I manually entered in the second code block.
Has anyone got any ideas?
=hour(a1)=7
will return true if the time of the date/time value in cell A1 is between 7 and 8 (AM) and will otherwise return false.
Excel stores dates as number of days since 1900 or 1904 depending on your setting and the time as a fraction of the days. So 11:59 am 4th of July 1960 is held internally as '22101.4993055556'.
As such you cannot do plain charactrer string comparisons on dates. However ther ar lots of nifty time/date functions available to you.
You probably want :
=IF(HOUR(B1) > 8,IF(HOUR(B1)<12,"YES","NO"),"NO")
You should use Excel functions, like HOUR(), to extract the parts of the times, and apply the logic tests to those extracted values.

Resources