Text string to a date conversion

Mark McInerney

Active Member
Joined
Apr 4, 2012
Messages
283
Office Version
  1. 365
Platform
  1. Windows
Hi Folks - Thanks in advance for checking this out.

I have a text string (see below) - is there a quick way to format this as DD/MM/YYYY?


Sunday, September 08, 2024
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
For a value in cell A1:
Excel Formula:
=DATEVALUE(TEXTAFTER(A1,", "))
and then format the cell as DD/MM/YYYY
 
Upvote 0
That didn't work for me. So if it doesn't work for you either try this:

Excel Formula:
=LET(sParts,TEXTSPLIT(A1,{","," "},,TRUE),
     yr, CHOOSECOLS(sParts,4),
     mth, CHOOSECOLS(sParts,2),
     d, CHOOSECOLS(sParts,3),
     DATEVALUE(d & " " & mth &" " & yr))
 
Upvote 0
Another option
Excel Formula:
=DATEVALUE(CONCAT(CHOOSECOLS(TEXTSPLIT(A1,{", "," "}),3,2,4)))
 
Upvote 0
That didn't work for me. So if it doesn't work for you either try this:

Excel Formula:
=LET(sParts,TEXTSPLIT(A1,{","," "},,TRUE),
     yr, CHOOSECOLS(sParts,4),
     mth, CHOOSECOLS(sParts,2),
     d, CHOOSECOLS(sParts,3),
     DATEVALUE(d & " " & mth &" " & yr))
I am guessing it may be different regional settings?
Here is the US, "September 08, 2024" is a valid date, so it works for me.
 
Upvote 0
@Joe4, since Fluff and I both use 08 September 2024 and that is what we have inside the DateValue, does that work with your date setting ?
(ie dd/mm/yyyy)
 
Upvote 0
@Joe4, since Fluff and I both use 08 September 2024 and that is what we have inside the DateValue, does that work with your date setting ?
I am not sure I understand how that comes into play here.

The question asked specifically about an entry that looks like this: "Sunday, September 08, 2024".
The formula I gave works on this, but apparently only if they are also using US Regional Settings.

Here are the results:
1728308471417.png


If they are not using US Regional settings, I agree with you, that my solution will probably not work for them, and will probably need to use one of your solutions.
I do not know which Regional Settings they are using, as they did not say.
 
Upvote 0
Hi Folks - Thanks everybody for looking at this.

My original data is on Column B - I need to extract the start date and finish date from Cell B2. I'm getting that error back when trying to extract the start date?

Best - Mark.

1728308617476.png
 
Upvote 0
Try adding TRIM like
Excel Formula:
=DATEVALUE(CONCAT(CHOOSECOLS(TEXTSPLIT(TRIM(C2),{", "," "}),3,2,4)))
 
Upvote 0
@Joe4 - I was just curious as to whether this errored out with a US Setting:
Excel Formula:
=DATEVALUE("08 September 2024")
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,635
Members
452,661
Latest member
Nonhle

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