The sure fire way is to strip each of the elements you need from the string then place them in the appropriate spots in the DATE
and TIME
functions. There are shorter methods which use DATEVALUE
and TIMEVALUE
.
Grab the year
=LEFT(A1,4)
Grab the month
=MID(A1,6,2)
Grab the day
=MID(A1,9,2)
Grab the hour
=MID(A1,12,2)
Grab the minutes
=MID(A1,15,2)
Grab the seconds
=MID(A1,18,2)
Time adjustment hour
=MID(A1,21,2)
Time adjustment minutes
=RIGHT(A1,2)
Time adjustment direction
=MID(A1,20,1)
Now that you have stripped out all the elements which are all still strings, you can dump them into DATE(year,month,day) and TIME(Hour, Minutes, Seconds)
=DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+TIME(MID(A1,12,2),MID(A1,15,2),MID(A1,18,2))+TIME(MID(A1,21,2),RIGHT(A1,2),0)*if(MID(A1,20,1)="-",-1,1)

NOTE: This answer assumes a leading 0 for single digits days