Formula to Extract Text Between First and Third Space

seaottr

Board Regular
Joined
Feb 10, 2010
Messages
60
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I know this is an easy one, and I'm clearly an idiot, but was hoping someone could help me figure out the formula to extract the characters between the first and third space.

Example:

A1 = "11/30/2017 02:23 PM America/Toronto"

Need to extract "02:23 PM"

Thank you in advance!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If you just need the text this will work
Code:
=MID(A1,SEARCH(" ",A1)+1,SEARCH(":",MID(A1,SEARCH(" ",A1)+1,999))+5)

If you need it to be a excel time then this will work. format the cell as time.
Code:
=TIMEVALUE(MID(A1,SEARCH(" ",A1)+1,SEARCH(":",MID(A1,SEARCH(" ",A1)+1,999))+5))
 
Upvote 0
Thanks Scott!!! You rock! And thank you for providing the solution for both text and time outputs!!!
 
Upvote 0
I know this is an easy one, and I'm clearly an idiot, but was hoping someone could help me figure out the formula to extract the characters between the first and third space.

Example:

A1 = "11/30/2017 02:23 PM America/Toronto"

Need to extract "02:23 PM"
Do your month and day values always have leading zeroes when they are single digits? If so...

=MID(A1,12,8)

for the time as a text value. If you want the time to be a real time value, just add zero to it...

=0+MID(A1,12,8)

If there might not always be a leading zero, then use this for the text time...

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),100,200))

and add zero to it for the real time value.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top