如何从Google文档或Excel中的date时间string中删除序号?
我有一个date时间的列表,碰巧有他们的序数(第一,第二,第三)。 这会导致使用date和转换为unix时间的问题。
如何从date中删除“rd”或“th”后缀?
示例date:
April 23rd Apr 24th Apr 30th May 1st May 7th May 8th May 15th May 21st May 22nd May 28th Jun 18th Jun 19th Jun 26th
尝试这个:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"st",""),"nd",""),"rd",""),"th","")
并将其转换为今年的“实际”date:
=--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"st",""),"nd",""),"rd",""),"th","")
或者更短(在Excel中工作,不确定Google):
=LOOKUP(1E+307,--SUBSTITUTE(A1,{"st","nd","rd","th"},""))
请务必将其格式化为date
如果date只是文本,并且总是有最后两个字母,那么它就是
=LEFT(A1,LEN(A1)-2)
如果你想检查那些信是在那里,你可以使用类似的东西
=IF(OR(RIGHT(A1,2)={"st","nd","rd","th"}),LEFT(A1,LEN(A1)-2),A1)
必须在Google表格中input为数组公式
=ArrayFormula(=IF(OR(RIGHT(A1,2)={"st","nd","rd","th"}),LEFT(A1,LEN(A1)-2),A1))