# Subtract time

I want to subtract time and multiply with the number .
For example
Cell A1 = 11:00PM
Cell A2 = 2:00 AM
Cell A3 = 4 ( any value )

In cell A4 i want  cell A2 - Cell A1 * Cell A3
###### Who is Participating?

x
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.

Commented:
=(A2-A1)*A3

Just make sure your formatting is set correctly to display a time.
Author Commented:
I tried this but getting a error ‘#####’

May be my formatting is wrong .
Can you help me with that
Commented:
That "error" is due to your column being too narrow. Widen it and it will display correctly.

To modify the formatting, right-click the cell and select "Format Number". Select your desired format from the Number tab.
Author Commented:
Correct answer should be 6 as A2-A1 =2 * 3

I have formatted cell A1 and cell A2  in h:mm format
7FE2F4D7-63FA-4565-B989-C7FE21054AE.jpeg
Author Commented:
I have also attached file so that you can have a look
Commented:
1:00 is less than 23:00 due to no date in the time values and results in the negative number, so we need to account for that. Use this formula instead...

=IF(A2<A1, A2-A1+1, A2-A1)*A3

BTW, the formatting of cells A1 and A2 won't have any impact. It's cell A4 that you need to format.

Experts Exchange Solution brought to you by

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

Excel & VBA ExpertCommented:
``````=MOD(A2-A1,1)*24*A3