I have a two dates in excel "1/2/2016 01:56:05" and "8/3/2016 06:21:46". How do I calculate the time difference between them in a format of days and hours?
Thanks!
I have a two dates in excel "1/2/2016 01:56:05" and "8/3/2016 06:21:46". How do I calculate the time difference between them in a format of days and hours?
Thanks!
Try this to include the spelled out hours and minutes:
Note that since the
m
comes immediately (ignoring the separator text in quotes) after theh
it will be interpreted as minutes and not monthsAssuming the dates are in cells
A1
andA2
, this will produce an answer with minutes as well in d:hh:mm format.Drop the
:mm
if you don't need minutes.If you want text:
If you want text with minutes:
Using double quotes alongside each other "escapes" the quote itself and allows the extra text to appear in the string. As Ron stated in his answer, the
m
following anh
in the same format string indicates minutes, so you can save an extra A2-A1 calculation by putting both in a single format.I prefer to work with dates as decimals. It looks cumbersome, but I'm much happier knowing what it's doing.
What I would usually do is to have A1-A2 in cell A3, then work out the component parts separately:
Or if you wanted to do it all in one formula:
or without using A3
It's not the prettiest or most efficient method but you can see how the times are calculated this way.