If you are trying to do this from a formula into another cell, and not in situ (For which, use "Text to Columns" as per Jeeped's answer), you can either combine DATE
and MID
, or use REPLACE
and convert with +0
or DATEVALUE
:
=DATE(MID(A1,1,4), MID(A1,5,2), MID(A1,7,2))
OR
=REPLACE(REPLACE(A1,7,0,"-"),5,0,"-")+0
OR
=DATEVALUE(REPLACE(REPLACE(A1,7,0,"-"),5,0,"-"))
(Where A1
is the date to convert)
The first formula just cuts the number up into 2018
01
01
and uses those as Year, Month and Day. The second 2 work by first Inserting (i.e. REPLACE
0 characters) a hyphen at position 7 ("201801-01"
) and then at position 5 ("2018-01-01"
) and converting the string back to a number/date.