Convert string WED FEB 23, 2009 to yyyy/mm/dd

kpaull

New Member
Joined
Apr 18, 2008
Messages
20
I have a file with the following string in the date field:

"8:26 am TUE FEB 24, 2009", how can I change this field to a string with yyyy/mm/dd HH:MM (24hr format)?

Thanks,
Kurtis
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try eg:

=SUBSTITUTE(SUBSTITUTE(RIGHT(A1,12),LEFT(RIGHT(A1,12),4),""),","," " &LEFT(RIGHT(A1,12),3))+LEFT(A1,FIND(" ",A1,7)-1)

formatted as yyyy/mm/dd hh:mm.
 
Upvote 0

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
Here are the components - Can you combine into a one cell formula?

Cell A1
8:26 am TUE FEB 24, 2009 B1=DATEVALUE(RIGHT(A1,12))

B2=TIMEVALUE(LEFT(A1,7))

B3=TEXT(B1,"yyyy/mm/dd") & " " & TEXT(B2,"HH:MM")
 
Upvote 0

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Jim,

The formula:

=DATEVALUE(RIGHT(A1,12))

doesn't work if the regional settings are eg English(United Kingdom). That's why I had to turn it into 24 FEB 2009.
 
Upvote 0

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
Thanks Andrew,

Being somewhat limited to my Virginia USA clients, I'm not International -- and
thus unfamiliar with such issues. LOL

Jim
 
Upvote 0

Ron Coderre

MrExcel MVP
Joined
Jan 14, 2009
Messages
2,316
With
A1: containing time/date text like your sample
example: 8:26 am TUE FEB 24, 2009

Try this (formatted as yyyy/mm/dd hh:mm):
Code:
B1: =DATE(RIGHT(A1,4),MONTH("1 "&LEFT(RIGHT(A1,12),4)),LEFT(RIGHT(A1,8),2))+
LEFT(A1,8)

In the above example, the formula returns: 2009/02/24 08:26

Is that something you can work with?
 
Upvote 0

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
WoooooW, Ron
That is Nice!!!!
Thanks for contributing here
 
Upvote 0

kpaull

New Member
Joined
Apr 18, 2008
Messages
20
With
A1: containing time/date text like your sample
example: 8:26 am TUE FEB 24, 2009

Try this (formatted as yyyy/mm/dd hh:mm):
Code:
B1: =DATE(RIGHT(A1,4),MONTH("1 "&LEFT(RIGHT(A1,12),4)),LEFT(RIGHT(A1,8),2))+
LEFT(A1,8)

In the above example, the formula returns: 2009/02/24 08:26

Is that something you can work with?

Rod this worked, you nailed it. Thanks!

Andrew and Jim thank you. Here is some feedback on your proposed formulas:

Try eg:

=SUBSTITUTE(SUBSTITUTE(RIGHT(A1,12),LEFT(RIGHT(A1,12),4),""),","," " &LEFT(RIGHT(A1,12),3))+LEFT(A1,FIND(" ",A1,7)-1)

formatted as yyyy/mm/dd hh:mm.


Andrew, using your above formula works, somewhat. I neglected to inform you that the date string changes with single digit dates: 9:43 am FRI MAR 2, 2009

And for your formula returns #VALUE! on the single digit dates.

Jim,

The formula:

=DATEVALUE(RIGHT(A1,12))

doesn't work if the regional settings are eg English(United Kingdom). That's why I had to turn it into 24 FEB 2009.

Kinda works. First of all my regional settings are English(USA). For 9:43 am FRI MAR 2, 2009
it returns 2009/03/02 00:00 when formatted as yyyy/mm/dd hh:mm. and returns the same with 9:43 am FRI MAR 20, 2009.

Thanks All, problem solved.
 
Upvote 0

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
One more option. Works with US date settings only,

=TRIM(MID(A1&" "&A1,13,LEN(A1)-3))+0

format as yyyy/mm/dd hh:mm
 
Upvote 0

kpaull

New Member
Joined
Apr 18, 2008
Messages
20
Barry,

It kinda works. It fails on string "10:18 am THU MAR 19, 2009" but works on string "9:19 am THU MAR 19, 2009"

Kurtis
 
Last edited:
Upvote 0

Forum statistics

Threads
1,191,183
Messages
5,985,172
Members
439,944
Latest member
Vangelis74

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
Top