简体   繁体   English

Excel公式获得时差

[英]Excel Formula to Get Time Difference

Checking out a formula that can take the difference of the time schedule. 检出一个公式,该公式可能会占用时间表的差异。 I have 我有

=ABS(TRIM(LEFT(M2,8))-TRIM(RIGHT(M2,8)))*24

but it doesn't take into consideration the hours that will go beyond 12AM (the next day). 但是它没有考虑到凌晨12点(第二天)以后的时间。 Example on the second row (4:00 PM - 12:00 AM). 第二行的示例(4:00 PM-12:00 AM)。 I am only interested with the time that it elapsed from the start time to the end time, which is supposed to be 8, but the result is different because of the difference in the date. 我只对从开始时间到结束时间所经过的时间感兴趣,应该是8,但是由于日期的不同,结果是不同的。 Any suggestions without adding a date column? 有没有添加日期列的建议吗?

在此处输入图片说明

You need to add 1 to the time when it goes to the next day. 您需要在第二天的时间加上1。

=IF(MID(M2,FIND("-",M2)+2,LEN(M2))<LEFT(M2,FIND("-",M2)-1),1,0)+MID(M2,FIND("-",M2)+2,LEN(M2))-LEFT(M2,FIND("-",M2)-1)

在此处输入图片说明

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

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