Difference between 2 cells containing time

fireslguk

Active Member
Joined
Nov 11, 2005
Messages
294
hi there, im in a stick n puzzled

want excel to calculate difference between 2 cells data in 1 row

e.g a1 12:00 b1 14:00 c1 = b1 minus a1 therefore 2:00

but when b1 = 02:00 then c1 = -10:00 but obviously i want to be 14 hrs

please note i have the cells custom format ##\:00 so a user just enters 1200 and the colon gets put in.

this is obviously a simple task however i cant think for the life of me
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Instead of:
B1-A1

Use:
=IF(A1>B1,B1-A1+2400,B1-A1)

Basically if the +2400 fixes the negative.

(Edit: fixed the cell references to match the above example)
 
Upvote 0
This is fine if you have round hours only but what if A1 is 1230 and B1 1400?

I'd suggest

=TEXT(B1,"00\:00")-TEXT(A1,"00\:00")+(A1>B1)

format as hh:mm
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

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