Calculating the difference between two times

Laird

New Member
Joined
Sep 13, 2008
Messages
13
I'm having difficulty getting Excel 2003 to subtract times. It seems to me that this should be easy, so probably I'm just making a mistake.

In Col A I have my arrival time (eg. 08:30)
- formula bar shows 08:30 AM

In Col B, I have departure time (which *might* be after midnight, but let's keep it simple for this example), eg. (23:00)
- formula bar shows 11:00 PM

I want to see the difference between the two times, which would be fifteen-and-a-half hours.

So, in Col C, I want a formula that will show Total Time On Site in Hours.Fraction-of-hour:

=B1-A1

Excel returns "0.3"

=Text(B1-A1,"hh")

Excel returns only "15" (not 15.5)

=Text(B1-A1,"hh.mm")
Excel returns 15.30 (not 15.5)

Q1. Advice on this problem?
Q2. Any thoughts about how to handle time differences that go beyond midnight?
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hello and welcome to MrExcel. Does this help?

<b>Sheet10</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:64px;" /><col style="width:64px;" /><col style="width:64px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="text-align:right; ">08:30</td><td style="text-align:right; ">23:00</td><td style="text-align:right; ">14.5</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">23:30</td><td style="text-align:right; ">07:15</td><td style="text-align:right; ">7.75</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >C1</td><td >=(MOD<span style=' color:008000; '>(B1-A1,1)</span>)*24</td></tr><tr><td >C2</td><td >=(MOD<span style=' color:008000; '>(B2-A2,1)</span>)*24</td></tr></table></td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4
 
Upvote 0
This site is good for time/date stuff, (Well lots of stuff actually!);

http://www.cpearson.com/Excel/datearith.htm

What you could do is format the cell where you have the calculation as "number", with 2 decimal places, and multiply is by 24, (which converts the number to hours...)

eg

A2 = 08:00
B2 = 23:30
C2 = (B2-A2)*24

Does this help?

Regards,

Simsy
 
Upvote 0
Yes nice site.
Thank you Simsy.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top