Solved

# Convert difference with dates and time to days hours amd minutes

Posted on 2012-09-20
269 Views
I want to convert the difference between two cells which contain dates into days, hours and minutes.
e.g.

30/7/2012 12:00
02/8/2012 13:15

to

3 Days 01:15

Can you give me a formula for this please?

Thanks
0
Question by:GordonMasson

LVL 39

Expert Comment

use formula
=a2-a1

then format that cell with the custom format
d "Days" hh:mm

Cells \ Format \ Format cells
Number \ Custom \ type in the format I gave you

Thomas
0

Author Comment

Hi Thomas

Thats what i tried and when you do the calculation, the cell does give you the correct number of days.

When you try to format it its fine if it doesnt roll over a month but when it does the format to d "Days" hh:mm is incorrect.

e.g.
30/07/2012 12:00
02/08/2012 13:15

will give you
3Days 01:15

But
30/07/2012 12:00
02/09/2012 13:15

will also give you
3Days 01:15
0

LVL 39

Accepted Solution

Then you can use this, knowing that it's no longer a number field and can't be added, sorted, etc. as such.

=INT(A2-A1) & " Days " & TEXT(A2-A1,"hh:mm")

Thomas
0

Author Closing Comment

Thanks Thomas
0

## Featured Post

### Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …