Extract Date from Text

larinda4

Board Regular
Joined
Nov 15, 2021
Messages
73
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I have this text, (and it changes but it'll always be annual. Feb-Jan, July-June, etc.) and I need to pull the starting date from the cell.

For the Period: May 01, 2021 to January 30, 2022

I currently have this formula but it'll only work for some of the months, not all. For example, it works for January but not for February/May.

=MID($A$5,SEARCH(": ",$A$5)+2,LEN($A$5)-SEARCH("to",$A$5))

I feel like I'm so close but I'm stumped.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
maybe
Book1
ABCD
5For the Period: May 01, 2021 to January 30, 2026 May 01, 2021
Sheet1
Cell Formulas
RangeFormula
D5D5=MID(A4,SEARCH(":",A4,1)+1,SEARCH("to",A4,1)-3-SEARCH(":",A4,1)+1)
 
Upvote 0
maybe
Book1
ABCD
5For the Period: May 01, 2021 to January 30, 2026 May 01, 2021
Sheet1
Cell Formulas
RangeFormula
D5D5=MID(A4,SEARCH(":",A4,1)+1,SEARCH("to",A4,1)-3-SEARCH(":",A4,1)+1)
Hi Kerry!

Thank you so much! It worked. I only made a slight change to your formula because it was bringing in a space at the beginning of the date.

=MID(A5,SEARCH(":",A5,1)+2,SEARCH("to",A5,1)-3-SEARCH(":",A5,1)+1)

You're the best! Have a great day!
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Hey Fluff,

I took your suggestion and updated my account details to indicate which excel version I am using. Thank you!
 
Upvote 0
Just an alternative:

Question.xlsx
AB
1For the Period: May 01, 2021 to January 30, 2022May 01, 2021
2May 01, 2021
Sheet9
Cell Formulas
RangeFormula
B1B1=TEXTBEFORE(TEXTAFTER(A1,": ")," to ")
B2B2=@DROP(TEXTSPLIT(A1,{": ";" to "}),,1)


If you'd remove the implicit intersection operator you'd end up with both the start- & end-date in seperate columns.
 
Upvote 0
Solution
try

=TRIM(MID(A5,SEARCH(":",A5)+1,SEARCH("to",A5)-SEARCH(":",A5)-1))
 
Upvote 0
I took your suggestion and updated my account details
Thanks for that.
As you have 365 another option is
Fluff.xlsm
AB
1
2For the Period: May 01, 2021 to January 30, 2022May 01, 2021
Main
Cell Formulas
RangeFormula
B2B2=INDEX(TEXTSPLIT(A2,{": "," to"}),,2)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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