Exracting Date from string

Son

Active Member
Joined
Mar 19, 2010
Messages
284
Hi, I have a string, which looks like the following phrase, and i need to extract the first date value that appears in it. The dates are, usually, preceeded by the character :, as it is shown in the example. In this case, i need to have 1/4/2011. Any ideas would be most appreciated!


JOHN ATE AN APPLE ON: 1/4/2011. THEN HE GOT HOME AND SLEPT. HE WOKE UP AT: 2/4/2011. TWO DAYS BEFORE, IE ON 31/3/2011 HE HAD GONE SKIING. AND TOMORROW HE WILL GO AGAIN.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
if that was written in a1 then this formula in B1 would get you the date.

=TEXT(MID(A1,FIND(":",A1,1)+2,9),"dd-mm-yyyy")
 
Upvote 0
Hi, I have a string, which looks like the following phrase, and i need to extract the first date value that appears in it. The dates are, usually, preceeded by the character :, as it is shown in the example. In this case, i need to have 1/4/2011. Any ideas would be most appreciated!


JOHN ATE AN APPLE ON: 1/4/2011. THEN HE GOT HOME AND SLEPT. HE WOKE UP AT: 2/4/2011. TWO DAYS BEFORE, IE ON 31/3/2011 HE HAD GONE SKIING. AND TOMORROW HE WILL GO AGAIN.
Try this...

=DATEVALUE(MID(SUBSTITUTE(A2,"."," "),FIND(":",A2)+1,11))

Format as Date
 
Upvote 0
Biff, great!!! Your formula did the trick!!! I had tried to apply the mid formula, but i had not gone far, especially with substituting the . with "". Thanks again!

Shadow, thank you very much for your suggestion, i'm only going with Biff's because your formula returns the "." at the end.

my thanks to both of you!
 
Upvote 0
Biff, great!!! Your formula did the trick!!! I had tried to apply the mid formula, but i had not gone far, especially with substituting the . with "". Thanks again!

Shadow, thank you very much for your suggestion, i'm only going with Biff's because your formula returns the "." at the end.

my thanks to both of you!
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

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