Parsing dates in LibreOffice Calc - is there a better/easier way?
You could use some sort of "lookup table" to translate the month names to dates (this solution is based on a solution proposed for the opposite operation - translate numbers to month names)
Just put the month names one after each other into a column on your spreadsheet, and define a named range on those cells (e.g. Monthnames
). Now, you can determine the month's number using =MATCH("Dec",Monthnames,0)
which results in 12
:
With such a table, you could replace the IF
statements by a single MATCH
call:
=DATEVALUE(CONCATENATE(MID(A2,8,2),"/",MATCH(MID(A2,4,3),Monthnames,0),"/",MID(A2,1,2)))
or on multiple lines:
=DATEVALUE( CONCATENATE( MID(A2,8,2), "/", MATCH( MID(A2,4,3), Monthnames, 0 ), "/", MID(A2,1,2) ) )
The formula above constructs a valid date value from your example strings:
Use MONTH to extract month value with dummy dd, yy values:
=DATEVALUE(CONCATENATE(MID(A2,8,2),"/",MONTH("1"&MID(A2,4,3)&"1"),"/",MID(A2,1,2)))