Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Difference between 2 times and dates

Hello,

The following problem we have to deal with:

On a sheet we have at cell A1 date number one and cell B1 time in the format
(hh:mm) and at cell A2 date number two en cell B2 time in the format
(hh:mm).
Now we have to calculate the time difference between date en time 1 and 2 in
cell C1.

How can I get this done?

Stefan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Difference between 2 times and dates

Assuming these are all in the correct numeric (not text) formats, in C1 the
formula would be:
=(A2+B2)-(A1+B1)
However, the result will appear strange unless you format the result (will
show as a date, probably 01/00/1900 (US date format)). If you know you
always will have a result less than 24 hours and you want to see hours and
minutes, format the cell with short time format ("hh:mm"); if you need the
difference as a total number of hours or minutes and it might be 24 hours,
you will need to adjust the formula:
=24*((A2+B2)-(A1+B1)) to give number of hours
=24*60*((A2+B2)-(A1+B1)) to give the number of minutes
You can also use the Round, Int, and Mod functions to round these
appropriately or to separate out the hours and minutes.

"Stefan Buijs" wrote:

Hello,

The following problem we have to deal with:

On a sheet we have at cell A1 date number one and cell B1 time in the format
(hh:mm) and at cell A2 date number two en cell B2 time in the format
(hh:mm).
Now we have to calculate the time difference between date en time 1 and 2 in
cell C1.

How can I get this done?

Stefan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Difference between 2 times and dates

To make life simple use the same cell to display the day and time
For instance you can type 01/01/05 10:00 in A1 and 02/01/05 11:00 in A2 then
in A3 just use the fomula = A2-A1. You will need to change the format of Cell
A3 to Time to one showing time in xx:xx:xx format or you can use custom
format like [h]:mm:ss. You will then see the time difference in hours,
minutes and seconds. Assuming you are in Europe with dd/mm/yy date system the
above formula and formatting will give you 25:00:00 as the answer since the
difference is 25 hours between 1st Jan 05 10:00 AM and 2nd Jan 05 11:00 AM.

Alok Joshi


"Stefan Buijs" wrote:

Hello,

The following problem we have to deal with:

On a sheet we have at cell A1 date number one and cell B1 time in the format
(hh:mm) and at cell A2 date number two en cell B2 time in the format
(hh:mm).
Now we have to calculate the time difference between date en time 1 and 2 in
cell C1.

How can I get this done?

Stefan



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between dates and times jmj713 Excel Discussion (Misc queries) 5 March 20th 09 11:12 PM
Calculating difference between times on 2 dates bollard Excel Worksheet Functions 4 June 10th 08 12:17 PM
Calculating the difference between 2 dates and times Dom Excel Discussion (Misc queries) 2 December 12th 07 04:56 PM
Need difference between two dates/times in hours ramsdesk Excel Worksheet Functions 10 April 25th 06 11:33 PM
Difference between 2 times and dates Stefan Buijs Excel Worksheet Functions 1 May 26th 05 02:21 PM


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"