Difference between 2 cells containing time

fireslguk

Active Member
Joined
Nov 11, 2005
Messages
286
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Asala42

Well-known Member
Joined
Feb 26, 2002
Messages
2,318
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)
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
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
 

Asala42

Well-known Member
Joined
Feb 26, 2002
Messages
2,318
d'oh! I missed that.

*grumbles something about poor caffiene levels*
 

Forum statistics

Threads
1,136,991
Messages
5,679,014
Members
419,799
Latest member
APInfa

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
Top