简体   繁体   中英

How to convert text “yyyy mmm ABC” to “yyyymm” date format using Excel formula?

Supposing I have cell value equal to

"2020 Aug ABC"

in Excel.

I want to convert this to 202008 date format using an excel formula because I would want to use the output value, that is, 202008 to perform some operation.

If your data is in A1 :

=LEFT(A1,4) & TEXT((DATEVALUE(MID(A1,6,3) & " 1")),"mm")
  • Import "2020 Aug ABC" in cell A1
  • Select A1 - Go to Data tab - Data Tools Area - Press Text to Columns
  • Select Delimited - Press Next - Select Space - Press Next
  • Press Finish
  • In D1 import =A1&RIGHT("0" & MONTH(DATEVALUE(B1&"1")),2)

Output:

在此处输入图像描述

Just another approach if your data is always same pattern.

=TEXT(DATEVALUE("01-"&MID(A1,6,3)&"-"&LEFT(A1,4)),"yyyymm")

Or just using:

=TEXT(MID(A1,6,3)&LEFT(A1,4),"yyymm")

在此处输入图像描述

A1 = 2020 Aug ABC

B1

=LOOKUP(9^9,LEFT(A1,4)/1%+FIND(TEXT(ROW($1:$12)*28,"mmm"),A1)^0*ROW($1:$8))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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