Extract Date-Different Formats

pto160

Active Member
Joined
Feb 1, 2009
Messages
477
Office Version
  1. 365
Platform
  1. Windows
I would like to extract the date even though the formats could be slightly different. The format in the text is year-month-day. The day can be written as 02 for example or 2. Here is an example.

Book1
AB
1TextWhat I want
2Café Nero-10-22-22-Paul Smith-Cash10/22/2022
3Café Nero-10-2-22-Paul Smith-Cash10/2/222
4Café Nero-10-02-22-Paul Smith-Cash10/2/2022
5Café Nero-03-02-22-Paul Smith-Cash3/2/2022
6Café Nero-03-2-22-Paul Smith-Cash3/2/2022
Sheet3
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
One possibility, assuming it immediately follows the first dash:

Book1
AB
1TextWhat I want
2Café Nero-10-22-22-Paul Smith-Cash10/22/2022
3Café Nero-10-2-22-Paul Smith-Cash10/2/2022
4Café Nero-10-02-22-Paul Smith-Cash10/2/2022
5Café Nero-03-02-22-Paul Smith-Cash3/2/2022
6Café Nero-03-2-22-Paul Smith-Cash3/2/2022
Sheet8
Cell Formulas
RangeFormula
B2:B6B2=AGGREGATE(14,6,MID(A2,FIND("-",A2)+1,{6,7,8,9,10})+0,1)
 
Upvote 0
Eric W, thank you so much. This really works. Actually the text is year-month-day and the formula works. In some circumstances the place name could have a dash. The date always begin with a 4 digit year like 2022 or 2023 if that would help.

Book1
AB
1TextWhat I want
2Café Nero-2022-10-22-Paul Smith-Cash10/22/2022
3Café Nero-2022-2-22-Paul Smith-Cash2/22/2022
4Café Nero-2022-02-22-Paul Smith-Cash2/22/2022
5Café Nero-2022-02-22-Paul Smith-Cash2/22/2022
6Café Nero-2022-2-22-Paul Smith-Cash2/22/2022
7Café-1 Nero-2022-2-22-Paul Smith-Cash#NUM!
Sheet3
Cell Formulas
RangeFormula
B2:B7B2=AGGREGATE(14,6,MID(A2,FIND("-",A2)+1,{6,7,8,9,10})+0,1)
 
Upvote 0
If the date always begins with a year, specifically 20xx, then we can search for "-20" instead of just "-":

Book1
AB
1TextWhat I want
2Café Nero-2022-10-22-Paul Smith-Cash10/22/2022
3Café Nero-2022-2-22-Paul Smith-Cash2/22/2022
4Café Nero-2022-02-22-Paul Smith-Cash2/22/2022
5Café Nero-2022-02-22-Paul Smith-Cash2/22/2022
6Café Nero-2022-2-22-Paul Smith-Cash2/22/2022
7Café-1 Nero-2022-2-22-Paul Smith-Cash2/22/2022
8Walmart-2023-11-8-John Doe-check11/8/2023
9Amazon-Smile-9-2000-12-31-Jane Roe-bitcoin12/31/2000
Sheet10
Cell Formulas
RangeFormula
B2:B9B2=AGGREGATE(14,6,MID(A2,FIND("-20",A2)+1,{6,7,8,9,10})+0,1)
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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