简体   繁体   English

Excel之间的时间返回相同范围内的不同值

[英]Excel between times returns different values in same range

I am using excel to calculate total minutes between times. 我使用excel来计算时间之间的总分钟数。

My calculation formula is like this: =INT((M3-L3)*1440) 我的计算公式如下: =INT((M3-L3)*1440)

Time1                   Time2                Minutes
5.1.2016  21:00:00      5.1.2016  22:00:00   59
5.1.2016  22:00:00      5.1.2016  23:00:00   60

First result is 59 but second result is 60. 第一个结果是59,但第二个结果是60。

What is the problem here? 这里有什么问题?

Excel internally represents date/time values as double precision floating point numbers. Excel在内部将日期/时间值表示为双精度浮点数。 The integer part represents the day. 整数部分代表日期。 The decimal part represents the time. 小数部分代表时间。 Floating point numbers have a finite precision (about 15 significant base-10 digits). 浮点数具有有限的精度(大约15个有效基数为10位)。 This means that some numbers can not be represented exactly which introduces small approximation errors that can lead to unexpected results. 这意味着某些数字无法准确表示,这会引入可能导致意外结果的小近似误差。

In your example, the first calculation is carried out as... 在您的示例中,第一次计算执行为...

=INT((5.1.2016 21:00 - 5.1.2016 22:00)*1440)
=INT((42491.875-42491.9166666667)*1440)
=INT(0.041666666664241*1440)
=INT(59.9999999965975)
=59

The second calculation is carried out as... 第二次计算是......

=INT((5.1.2016 22:00 - 5.1.2016 23:00)*1440)
=INT((42491.9166666667-42491.9583333333)*1440)
=INT(0.041666666664241*1440)
=INT(60.0000000069849)
=60

This is a limitation of floating point math. 这是浮点数学的限制。

In this specific case, you could get the desired results by replacing INT(number) with ROUND(number,0) or MROUND(number,1) 在这种特定情况下,您可以通过用ROUND(数字,0)或MROUND(数字,1)替换INT(数字)来获得所需的结果

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

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