0

Okay, so I have two cells:

Start           End
11:31:37.644    11:31:51.269

I'd like to subtract the two and return the remaining time which should equal something around 14 seconds.

Edit for more information:

My values I'm inputting are like so:

113137.644
113151.269

and I have a custom formatter set to: 00\:00\:00.000 to display what you see at the very top.

1
  • The problem is my value isn't 11:31:37.644, it's 113137.644 and is only being displayed as 11:31:37.644
    – Wesley
    Dec 17, 2012 at 19:05

3 Answers 3

2

It would be better if you could input the values as real time values then you can just use a simple subtraction

=A2-A1

...but with the values as they are you can do a conversion and subtraction all in one using TEXT function, e.g. in A3 use this formula

=TEXT(A2,"00\:00\:00.000")-TEXT(A1,"00\:00\:00.000")

format A3 as [h]:mm:ss.000 to get 0:00:13.625 for your example

Assumes times are on the same "day", if you need to pass midnight you can revise formula to

=MOD(TEXT(A2,"00\:00\:00.000")-TEXT(A1,"00\:00\:00.000"),1)

1
  • I could have sworn I tried it with TEXT(A2,"00\:00\:00.000") but got an #VALUE error; I must have forgotten the slashes. Anyways, nice clean solution. Dec 17, 2012 at 19:22
1

You need to use the MID function to grab each section of the time, like this:

=MID(A1,1,2)&":"&MID(A1,3,2)&":"&MID(A1,5,2)&"."&MID(A1,8,3)

This will change 113137.644 to 11:31:37.644.

You can then do the math on it like this (all in one cell, but broken up here for readability):

=TEXT(MID(B1,1,2)&":"&MID(B1,3,2)&":"&MID(B1,5,2)&"."&MID(B1,8,3), "hh:mm:ss.000") 
 - 
 TEXT(MID(A1,1,2)&":"&MID(A1,3,2)&":"&MID(A1,5,2)&"."&MID(A1,8,3),"hh:mm:ss.000")

That should give you 0.000157697. Change the field's custom format to hh:mm:ss.000 to give you 00:00:13.625.

0

You can use this formula to convert your values to time

=(LEFT(A1,2)+(MID(A1,3,2)+RIGHT(A1,LEN(A1)-4)/60)/60)/24

You can then subtract and convert back using the following formula

=TEXT(B1,"hhmm")&TEXT(MOD(B1*24*60,1)*60,"00.000")

But it would probably be better for you to actually use proper decimal values in fractions of days or hours rather than this you can't calculate anything with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.