Hello,
I have a column of cells with the following text format, "2:03pm September 27th – 3:12pm September 27th".
I want to extract the two date-time combinations into separate columns in Excel date-time format to enable further processing (e.g. to calculate duration of the event and to sort event rows into date time order)
So far I have found methods online to break the text into two elements (assuming the above text is in cell A1):
extracts the first date-time combination
and
extracts the second date-time combination.
I can extract the day of the month as a number from the extracted date-time result using (assuming the result of the first date-time extraction was placed in cell A2):
The month can be extracted as a number using:
And the time can be extracted in Excel format via:
Let us assume the YEAR is the current Excel year.
Combining the day number + month number + current year + the time into a single cell in Excel datevalue format can be done (assuming the day number value is in cell A4, the month number in A5 and the time in A6 respectively) via:
Is there a better/more elegant method of extraction to achieve the same result?
Ciao
I have a column of cells with the following text format, "2:03pm September 27th – 3:12pm September 27th".
I want to extract the two date-time combinations into separate columns in Excel date-time format to enable further processing (e.g. to calculate duration of the event and to sort event rows into date time order)
So far I have found methods online to break the text into two elements (assuming the above text is in cell A1):
Code:
=LEFT(A1,FIND(" – ",A1)-1)
and
Code:
=RIGHT(A1,LEN(A1)-(FIND(" – ",A1)+4))
I can extract the day of the month as a number from the extracted date-time result using (assuming the result of the first date-time extraction was placed in cell A2):
Code:
=VALUE(MID(A2,LEN(A2)-3,2))
The month can be extracted as a number using:
Code:
=MONTH(DATEVALUE(MID(A2,FIND(" ",A2)+1,FIND(" ",A2,FIND(" ",A2)+1)-FIND(" ",A2))&" 1"))
And the time can be extracted in Excel format via:
Code:
=TIMEVALUE(SUBSTITUTE(LEFT(A2,FIND(" ",A2)-1),"pm"," pm"))
Let us assume the YEAR is the current Excel year.
Combining the day number + month number + current year + the time into a single cell in Excel datevalue format can be done (assuming the day number value is in cell A4, the month number in A5 and the time in A6 respectively) via:
Code:
=DATEVALUE("01"&"/"&TEXT(DATE(2000,A5,1),"mm"))+(A4-1)+A6
Is there a better/more elegant method of extraction to achieve the same result?
Ciao