Forum Discussion
Abdellatif1995
May 18, 2022Copper Contributor
Convert text to date
Hi All, I need help with this issue please , I have this column with ages written in format like for example ( 2 years , 1 year , 13 month , 8 weeks ) I want to convert all these data to reflect ...
- May 18, 2022
in B2:
=LET( delimP, FIND(" ",A2), number, --LEFT(A2,delimP-1), period, SUBSTITUTE(MID(A2,delimP+1,LEN(A2)-delimP),"s",""), SWITCH(period, "year", number*12, "month", number, "week", number/4, "Unknown" ) )If you don't run Excel 2021 or 365:
=IFERROR( VALUE(LEFT(A2,FIND(" ",A2)-1)) * LOOKUP( SUBSTITUTE(MID(A2,FIND(" ",A2)+1,LEN(A2)-FIND(" ",A2)),"s",""), {"month","week","year"}, {1,0.25,12} ), "Unknown" )
OliverScheurich
May 18, 2022Gold Contributor
An alternative could be a macro. In the attached file you can click the button in cell E2 to start the macro.