简体   繁体   English

Excel 将日期时间转换为值

[英]Excel convert date time to value

Date time appears as "Tue Nov 09 2021 20:27:51 GMT-0500 (Eastern Standard Time) How to convert to a value that I can use to calculate time difference between two dates?日期时间显示为“Tue Nov 09 2021 20:27:51 GMT-0500(东部标准时间)如何转换为可用于计算两个日期之间时差的值?

Do you want to show the difference in time(hours) or days?你想显示时间(小时)或天的差异吗? For days you can use a column with the following formula对于几天,您可以使用具有以下公式的列

=CONCAT(MID(A3,9,2),"-",MID(A3,5,3),"-",MID(A3,12,4))

where A3 is your cell containing the string "Tue Nov 09 2021 20:27:51 GMT-0500 (Eastern Standard Time)".其中 A3 是包含字符串“Tue Nov 09 2021 20:27:51 GMT-0500(东部标准时间)”的单元格。 This will be converted to 09-Nov-2021.这将转换为 2021 年 11 月 9 日。 You can then use a normal subtraction (AB) to calculate the day difference between 2 dates.然后,您可以使用正常减法 (AB) 来计算 2 个日期之间的天差。

Use MID:使用中间:

=MID(REPLACE(A1,11,0,","),5,21)-TIME(5,0,0)

Then format it how you would like.然后按照你的意愿格式化它。

在此处输入图像描述

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

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