Excel convert TEXT (28th April 2017) TO DATE

2019-09-17 05:46发布

I have some dates in my excel spreadsheet that have th,nd,st and rd in the string so I am currently struggling to convert them to a date format of dd/mm/yyyy.

How would I be able to do this using a formula? 28th April 2017 = 28/04/2017

Thanks

标签: excel
3条回答
Root(大扎)
2楼-- · 2019-09-17 06:23

With a formula:

=--(LEFT(A1,MIN(SEARCH({"th","st","nd","rd"},A1 & "thstndrd"))-1)&" " & MID(A1,MIN(SEARCH({"th","st","nd","rd"},A1 & "thstndrd"))+3,LEN(A1)))

This is an array formula and needs to be confirmed with Ctrl-Shift-Enter.

Then format as dd/mm/yyyy

enter image description here

查看更多
啃猪蹄的小仙女
3楼-- · 2019-09-17 06:24

You could give a try with this formula as well,

=IF(ISNUMBER(VALUE(LEFT(A1,2))),TEXT(REPLACE(A1,3,2,""),"mm/dd/yyyy"),TEXT(REPLACE(A1,2,2,""),"mm/dd/yyyy"))

The formula finds the numeric value in first two places and formats the date accordingly. The advantage of this formula is, you can modify the mm/dd/yyyy format as per your needs. There would not be a necessity to change the format of the cell.

enter image description here

查看更多
时光不老,我们不散
4楼-- · 2019-09-17 06:27

The text being in A1:

=DATEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"th",""),"st",""),"nd",""),"rd",""))
查看更多
登录 后发表回答