日期时间的差异 [英] Difference of Datetimes

查看:83
本文介绍了日期时间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel 2007中, 我想对以下日期进行日期差异:

In Excel 2007, I want to do date difference for the following dates as below:

  A                         B                          C
1 Date1                     Date2                      Difference of A and B
2 2009.11.28 01:25:46:0287  2009.11.28 01:25:46:0287   ?
3 2009.11.28 01:25:46:0443  2009.11.28 01:25:46:0443   ?

请帮助我在Excel 2007中提供一个公式,以获取上述日期的差值.

Kindly help me with a formula in Excel 2007, to get the difference of the above dates.

推荐答案

Excel将日期存储为等于=自01/01/1900以来的天数的数字,因此您可以取其差值.即

Excel stores Dates as a number equal = number of days since 01/01/1900, hence you can just take the difference. i.e.

C2 = A2-B2 

几天之内就能给您带来不同.

Will give you difference in days.

例如,如果您想要在几秒钟内完成,则:

If you want it in seconds, for example, then:

C2 = (A2-B2) * 24 * 60 * 60

如果您需要分析字符串(包括几分之一秒),则:

If you need to parse the string including the fractions of seconds then:

=DATE(MID(A2,1,4),MID(A2,6,2),MID(A2,9,2))+TIME(MID(A2,12,2),MID(A2,15,2),MID(A2,18,2))+MID(A2,21,4)/(24*60*60*10000)

将A2转换为Excel DateTime.我建议您将其放在单元格d2中并复制到e2.然后,C2可以基于这些.

Will convert A2 into an Excel DateTime. I suggest you put it in cell d2 and copy to e2. C2 can then be based off those.

这篇关于日期时间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆