简体   繁体   中英

Calculate time difference in milliseconds from a value i got using a formula in excel

So I'm using the MID value to get the time out of the string, since my excel is in German the command is:

=TEIL(A2;11;13) 

from

2022-09-08 11:50:16,765 INFO

Which leaves me with

11:50:16,765

I get the second time value in the same way. I have tried splitting the seconds and milliseconds by both. [DOTS] &, [COMMAS].

After I want to calculate the time difference I subtract the higher value (second time) from the lower one (first time), although my result is

#WERT. (#VALUE!).

I have looked up for solutions already and figured out that for the German region I should use the time format hh:mm:ss,000 instead of hh:mm:ss.000 [COMMA instead of DOT]. Used this in all 3 cells (B2, C2 & D2 etc.).

Since it didn't work, I´ve tried to simply write some values in milliseconds as a text and divide them using the German time format and it worked (see columns E & F).

So my conclusion is that I am not able to subtract the values from each other because I am getting them from a formula? (Please correct me if I am wrong).

在此处输入图像描述

By using 11;13 in you mid you are capturing the leading space and this is causing Excel not to be able to convert the string to a true time.

Either TRIM the results in the subtraction:

=TRIM(C2)-TRIM(B2)

Or better yet, grab just the numbers without the spaces:

=MID(A2,12,12)

or in German:

=TEIL(A2;12;12)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM