简体   繁体   English

从我使用 excel 中的公式得到的值计算时间差(以毫秒为单位)

[英]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:所以我使用 MID 值从字符串中获取时间,因为我的 excel 是德语,命令是:

=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. #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].我已经查找了解决方案,并发现对于德国地区,我应该使用时间格式 hh:mm:ss,000 而不是 hh:mm:ss.000 [COMMA 而不是 DOT]。 Used this in all 3 cells (B2, C2 & D2 etc.).在所有 3 个单元格(B2、C2 和 D2 等)中都使用了这个。

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).由于它不起作用,我尝试简单地以毫秒为单位写一些值作为文本并使用德国时间格式将它们划分并且它起作用(参见列 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.通过在中间使用11;13您正在捕获前导空格,这导致 Excel 无法将字符串转换为真实时间。

Either TRIM the results in the subtraction:要么 TRIM 减法中的结果:

=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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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