Subtracting times

redfour

New Member
Joined
Oct 31, 2005
Messages
2
Subtracting one time from another is not as straightforward as your tip suggests.

Subtracting 05:00hrs from 22:00hrs is simple, but subtract 22:00hrs from 05:00hrs!

Using the IF statement can get round this problem.

Assume cell B1 is to be deducted from A1 and the result to go in C1.

To overcome the problem you need to add 24hrs to the value of A1 if it is less than the value of B1.

The formula =IF(B1>A1,(A1+24-B1),A1-B1) solves the problem.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
Hi redfour,

Is this a question or an answer?

To get the difference between two times, start time in A1 and end time in B1

=B1-A1+(A1>B1)

format as h:mm
 

Forum statistics

Threads
1,136,600
Messages
5,676,727
Members
419,647
Latest member
usas12gthr

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