simple question (subtracting time)..

Hoffman

Board Regular
Joined
Oct 19, 2007
Messages
220
Office Version
  1. 365
Platform
  1. MacOS
Thanks in advance..
I have always gotten great help from this fantastic community...

I would like a way to subtract time amounts (not actual time of day) from 2 cells.

So A1 says 4 hours 12 min 8 sec
B1 says 2 hours 8 min 7 sec

and
c1 needs to be the difference?

C1 2 hours 4 min 1 sec (want excel to do, right now I am doing by hand)

so in short, in the cells I need to write the amount of hours min and seconds and then I need a way to find the difference in cells.

thanks very much and wishing terrifichealth for 2023

Barry
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Time is a number so A1-B1 would do. Format column as time. That should do it.

EDIT: Owe, wait the cells contain the time value literally as x hours y mins and z secs?
 
Upvote 0
yes, I saw something like this online but they had the info in the cell separated by commas I think

I want to do the same so like
4 days, 2 hours, 1 min
 
Upvote 0
You do not show the version of Excel that you are using.
The following uses functions from the latest version of Excel.
D1 custom format h "hours" mm "min" s "sec"

Time.xlsm
ABCD
14 hours 12 mins 8 Sec2 hours 8 min 7 sec2:04:012 hours 04 min 1 sec
212 hours 42 mins 8 Sec8 hours 50 min 40 sec3:51:283 hours 51 min 28 sec
3
11b
Cell Formulas
RangeFormula
C1:C2C1=TIME(TEXTBEFORE(A1," "),TEXTAFTER(TEXTBEFORE(A1," ",3)," ",2),TEXTAFTER(TEXTBEFORE(A1," ",5)," ",4))-TIME(TEXTBEFORE(B1," "),TEXTAFTER(TEXTBEFORE(B1," ",3)," ",2),TEXTAFTER(TEXTBEFORE(B1," ",5)," ",4))
D1:D2D1=C1
 
Upvote 0
Hi to all.
With this format in A1 and B1: 4 hours, 2 min, 1 sec use in C1:

Excel Formula:
=HOUR(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))
-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" hours, "
 & MINUTE(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))
-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" min, "
 & SECOND(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))
-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" sec"


:eek::eek: :biggrin:
 
Last edited by a moderator:
Upvote 0
Solution
Hi sorry
Excel for Mac v16.56

I will try both and report back.

Thanks
Barry
 
Upvote 0
If you do not have the Functions TextBefore and TextAfter, try Data TextToColumns with separator space.

Time.xlsm
ABCDEFGHIJKLMNO
44 hours 12 mins 8 Sec4hours12mins8Sec2 hours 8 min 7 sec2hours8min7sec2:04:01
512 hours 42 mins 8 Sec12hours42mins8Sec8 hours 50 min 40 sec8hours50min40sec3:51:28
11b
Cell Formulas
RangeFormula
O4:O5O4=TIME(B4,D4,F4)-TIME(I4,K4,M4)
 
Upvote 0
Hi to all.
With this format in A1 and B1: 4 hours, 2 min, 1 sec use in C1:

=HOUR(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" hours, " & MINUTE(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" min, " & SECOND(TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," hours, ",":")," min, ",":")," sec",""))-TIMEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1," hours, ",":")," min, ",":")," sec","")))&" sec"

:eek::eek: :biggrin:

Thanks- I tried this and I copied your formula into C1, it gave me back #value which I think means an error in the code?
any suggestions?

Barry
 

Attachments

  • BF.jpg
    BF.jpg
    52.9 KB · Views: 4
Upvote 0
If you do not have the Functions TextBefore and TextAfter, try Data TextToColumns with separator space.

Time.xlsm
ABCDEFGHIJKLMNO
44 hours 12 mins 8 Sec4hours12mins8Sec2 hours 8 min 7 sec2hours8min7sec2:04:01
512 hours 42 mins 8 Sec12hours42mins8Sec8 hours 50 min 40 sec8hours50min40sec3:51:28
11b
Cell Formulas
RangeFormula
O4:O5O4=TIME(B4,D4,F4)-TIME(I4,K4,M4)
Dave I am trying to keep this to just 3 cells only
A1 4 hrs, 7 min, 8 sec
B1 2 hrs, 2 min, 3 sec
C1 has the formula to subtract the two cells.

thoughts?

Barry
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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
Back
Top