How to subtract date and time

dprice2000

New Member
Joined
Aug 10, 2006
Messages
8
I have:

Cell A1 03/12/2009 22:28:00
Cell B1 04/12/2009 10:40:00

I need to find out how many hours between these two dates and times.

Also need to then use that result in another formula so using Custom [hh]:mm doesn't seem to work.

Any help?

Thank you
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

rs2k

Well-known Member
Joined
Aug 15, 2004
Messages
1,413
Try;

=B1-A1

and format as '[h]:mm'

This gives 12:12, how do you mean that it is being used in another formula, and doesnt seem to work?

Can you explain a bit more?

Cheers
Colin
 

dprice2000

New Member
Joined
Aug 10, 2006
Messages
8
Thanks for the answer.

Once i've found how many hours, I want to create another formula to see if the amount is over or under 24. Just doesn't seem to work.

=IF(C1<24,"On time","Over")


Thanks,
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
24 hours is one day so it's:

=IF(C1<1,"On time","Over")

Also - if your timestamps are as per above you're cool, i.e. the date's are there too. However if you're working with JUST times, without dates in them, then you need something like:


=(B1 < A1) + B1-A1<A1) p + B1-A1<>
To handle cases where you start at 10:00 pm and end at 3:00 am (assuming it's 3 am the next day).
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,123,158
Messages
5,600,052
Members
414,357
Latest member
Gemma_R

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