Date/time difference

C

Caroline

Hello,
I have a worksheet with 2 columns with date and time. I want to calculate
the difference between date 1 and date 2. The way it is now, I have a formula
that says:
=(B1-A1)*24 and this gives me a result in hours and decimal (for example
7.98).
However, I would like the result to show as #of days/#of hours/#minutes.
Most results will be 0 day but for results with more than one day (24 hours)
I would rather not have for example 120.5 hours but instead "5 days, 3 hours
and 4 minutes" (or whatever it is)...
Any way I can do that?
Thank you,
Caroline
 
P

Pete_UK

This seems a bit clumsy, so maybe someone else can improve on it. With
the earlier date/time in A1 and the later date/time in B1, try this
formula in C1:

=INT(B1-A1)&" day"&IF(INT(B1-A1)=1,", ","s, ")&INT(MOD(B1-A1,1)*24)&"
hours "&INT(MOD((B1-A1)*24,1)*60)&" minutes"

It gives results like:

09/09/2009 23:18 11/09/2009 20:22 1 day, 21 hours 4 minutes
09/09/2009 20:18 11/09/2009 20:22 2 days, 0 hours 4 minutes
10/09/2009 20:22 11/09/2009 20:22 1 day, 0 hours 0 minutes

Hope ths helps.

Pete
 
D

David Biddulph

Falls over when the number of days goes beyond 31.
[And, of course, you don't need the *24.]
 
P

p45cal

custom format your cell to
D\" DAYS, \"HH\" HOURS AND \" MM\" MINUTES\"
but falls over when differences are greater 30 or so days
 
B

barry houdini

You can combine INT and TEXT functions to cope with periods 32 days or
over, i.e.

=INT(B1-A1)&" days, "&TEXT(B1-A1,"h"" hours and ""m"" minutes """)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top