简体   繁体   English

如何将Excel中异常的日期时间格式分别转换为年,月,日和时间单元格?

[英]How to convert unusual datetime formats in excel to year, month, day, and time cells respectively?

I need to sort a large number (100k+) rows of Excel cells by date and time, however, the date and time for each row are currently provided in a single cell in the following format: 我需要按日期和时间对大量(100k +)行的Excel单元格进行排序,但是,当前每一行的日期和时间都在单个单元格中以以下格式提供:

09/03/2018@01:15:00.000 PM 09/03/2018 @ 01:15:00.000 PM

For whatever reason, I'm unable to convert this value into separate cells for year, month, date, and time respectively. 无论出于何种原因,我都无法将此值分别转换为年份,月份,日期和时间的单独单元格。 Any attempts thus far have produced #VALUE ! 到目前为止,任何尝试都产生了#VALUE! errors. 错误。

I'm mostly familiar with basic methods of manipulating date and time values in Excel, and I've already attempted using DATETIME as well as converting to date, text, datetime serial. 我最熟悉在Excel中操作日期和时间值的基本方法,并且我已经尝试过使用DATETIME以及转换为日期,文本和日期时间序列。

As mentioned, I've attempted every possible solution that comes up as a result of a google search for "datetime conversion in Excel" and I'm aware of the plethora of existing questions on stackoverflow along this same vein, but none of them really addressed this specific format that I just can't seem to overcome. 如前所述,由于Google搜索“ Excel中的日期时间转换”,我已经尝试了所有可能的解决方案,并且我也知道有很多关于stackoverflow的现有问题,但是没有一个是真正的问题。解决了我似乎无法克服的这种特定格式。

The problem is that Excel sees 09/03/2018@01:15:00.000 PM as a text string. 问题是Excel将09/03/2018@01:15:00.000 PM视为文本字符串。

To make it a date we need to remove the @ with SUBSTITUTE: 为了使其成为日期,我们需要使用SUBSTITUTE删除@

--SUBSTITUTE(A1,"@"," ")

then you can use the standard YEAR(),MONTH(),DAY() 那么您可以使用标准的YEAR(),MONTH(),DAY()

=YEAR(--SUBSTITUTE(A1,"@"," "))

... ...

and so on. 等等。

Time would be: 时间将是:

=MOD(--SUBSTITUTE(A1,"@"," "),1)

And format the output HH:MM:SS 并格式化输出HH:MM:SS

在此处输入图片说明

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

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