# Subtracting time in excel

I want to subtract time.
Cell C10 and C11 contains time .
CEll D10 contains C11 - C10

Ideally the answer should be  4 but i am getting some negative value .
Capture.PNG
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ConsultantCommented:
Hi,

You are effectively subtracting 21 hours from 1 hour to get minus 20 hours.

Excel measures time as a fraction of a day (24 hours) so minus 20 hours = -20/24 = -0.833333....

To get four, you could just add 'one' to your answer = -0.8333 +1 = 0.166666

You can then display that as hours (HH:mm format for example) or multiply by 24 to go from days to hours:

0.166666 x 24 = 4 (hours)

See F10 and F11 in the attached for examples.

Alan.
EE-29088485-Version1.xlsx
0
Commented:
or in cell D10, try apply formula such as:

``````=IF(C11<C10, TEXT((TODAY()+1+C11)-(TODAY()+C10),"h"),TEXT(C11-C10,"h"))
``````
0
Commented:
I provided you with the answer in your previous question - https://www.experts-exchange.com/questions/29088470/Subtract-time.html
0
Author Commented:
@alan  formula you gave in excel file will work fine for all the negative values .
But what about the positive ones .
EE-29088485-Version1.xlsx
0
Excel & VBA ExpertCommented:

``````=MOD(C11-C10,1)*24
``````
and format the formula cell as General.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.