[英]date conversion formula in excel
I have some dated in this format "09-MAY-13 06.42.46.097127000 PM" and need to convert to this format "2013-05-09T18:42:47.132Z". 我有一些日期格式为“ 09-MAY-13 06.42.46.097127000 PM”,并且需要转换为此格式“ 2013-05-09T18:42:47.132Z”。 my goal is to find out which happend earlier. 我的目标是找出较早发生的情况。 I am not sure how to format these dates. 我不确定如何格式化这些日期。
2013-05-09T18:42:47.132Z 09-MAY-13 06.42.46.097127000 PM
2013-05-08T20:56:55.821Z 06-MAY-13 03.22.09.129443000 PM
2013-05-08T20:51:45.287Z 06-MAY-13 03.03.22.975700000 PM
2013-05-08T20:55:34.719Z 06-MAY-13 10.40.55.924181000 PM
How I can do that?? 我该怎么做?
I originally posted an answer which converted one of your formats to the other. 我最初发布的答案将您的一种格式转换为另一种格式。 I now see that you need to compare
them, so you can convert this format in A2 to date/number values .... 现在,我需要compare
它们,因此可以将A2中的这种格式转换为日期/数字值...。
09-MAY-13 06.42.46.097127000 PM 2013年5月9日06.42.46.097127000 PM
.....with this formula .....用这个公式
=SUBSTITUTE(SUBSTITUTE(A2,".",":",1),".",":",1)+0
and this format in A3 而这种格式在A3中
2013-05-09T18:42:46.097z 2013-05-09T18:42:46.097z
....with this formula ....用这个公式
=SUBSTITUTE(SUBSTITUTE(A3,"T"," "),"z","")+0
You can format the results how you like, leave as numbers or format as m/d/yyyy hh:mm:ss.000
or similar. 您可以随意设置结果格式,保留为数字或格式为m/d/yyyy hh:mm:ss.000
或类似格式。 you can now compare easily with a formula like 您现在可以轻松地将公式与
=B2>B3
or get the smaller or larger with MIN or MAX 或以MIN或MAX变小或变大
If have a value of your original style in cell A1, place the following formula in a different cell: 如果在单元格A1中具有原始样式的值,则将以下公式放在另一个单元格中:
=DATE((2000+MID(A1,8,2)),MATCH(MID(A1,4,3),{"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"},0),LEFT(A1,2))+TIME(MID(A1,11,2)+IF(RIGHT(A1,2)="PM",12,0),MID(A1,14,2),MID(A1,17,12))
Then, in that target cell, apply the following format: 然后,在该目标单元格中,应用以下格式:
yyyy-mm-ddThh:mm:ssZ
Please note the following: 请注意以下事项:
To add to Joe's answer... To get Excel to compare one column to the other you need to do the same sort of manipulation from the first column as the second. 要添加到Joe的答案中……要使Excel将一个列与另一个列进行比较,您需要从第一列开始进行与第二列相同的操作。
That would look like 看起来像
=DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,5))
Once you have a new column for each of these transformations it should be simple to have Excel compare them. 一旦对每个转换都有一个新列,使Excel比较它们应该很简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.