Text to Numbers

Simon Pipe

New Member
Joined
Sep 20, 2011
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a worksheet with the following in one cell:

Aug 1 2011 1:00AM

It is formatted in TEXT and I am unable to change them to date format in the normal way.

Ideally I would like to convert it to dd/mm/yy (not bothered about the time)

Any ideas?

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If the month is always formatted as 3 letters than it shouldn't be a problem.

All you need is an alphabetic lookup table to reference, and with the LEFT, MID, LOOKUP, and DATE functions you should be able to get it all setup.
 
Upvote 0
Have you tried =DATEVALUE(LEFT(A1,11)) or even =DATEVALUE(A1)

I can't test at the moment, but one of these might work.
 
Upvote 0
Hi,

Doubledaffy - thanks but I have no idea how to do any of what you have suggested...

Mikerickson - Trred both of those with no success.

If anyone could help would be grateful.

Thanks, Simon
 
Upvote 0
Give this formula a try...

=--REPLACE(REPLACE(A1,LEN(A1)-1,0," "),FIND(" ",A1,FIND(" ",A1)+1),0,",")
 
Upvote 0
Thanks but no good - just comes up #VALUE!
I don't think all those characters that look like spaces are really spaces; rather, I think one or more of them are non-breaking spaces (ASCII 160) like you sometimes get when copying data from the Internet. See if this formula works for you...

=--REPLACE(REPLACE(SUBSTITUTE(A1,CHAR(160)," "),LEN(A1)-1,0," "),FIND(" ",SUBSTITUTE(A1,CHAR(160)," "),FIND(" ",SUBSTITUTE(A1,CHAR(160)," "))+1),0,",")
 
Upvote 0
Simon:

If the month is always the three letter code you can make a table. The three letter month in one column, and the corresponding number in another. E.g. Jan in cell A1 and 1 in cell B1. Then you can select the whole table, and sort it alphabetically (this way we can use lookup and avoid the long code of OFFSET/MATCH).

I'll assume that the string you want to parse is in cell A1
After this we can just pluck the right values. We know the first three characters will form the month string. So we use LEFT(A1,3). Then we know day is either one or two digits so we'll just indiscriminately take three and include the space using MID(A1,4,3). Last we need to get the year string. Again we have to worry about the day being one or two digits, but we have the space buffer that we can pick up and discard whenever we want. So lets use MID(A1,7,5). For a one digit day it will pick up an extra space before the year, and for a two digit day it will have an extra space after the year, but we don't really care.

Now we just have to make this into a useful date value. The first thing to do change the month string into a value. Using the table we already setup (assuming its sorted alphabetically, the months are in F1:F12 and the corresponding numbers are in G1:G12, but you can put it anywhere) we can do LOOKUP(LEFT(A1,3),F1:F12, G1:G12). Notice the LEFT(A1,3) from before. We now have a numeric Year, Month and Day...which is all we need.

So all together it looks like:
=Date(YEAR, MONTH, DAY)
=Date(MID(A1,7,5),LOOKUP(LEFT(A1,3),$F$1:$F$12,$G$1:$G$12),MID(A1,4,3))

That should take care of it. You can work on the steps in separate cells to play around and see how they work. That's what I usually do before putting it all into one formula in a cell.

Good luck
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

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