Text to Column doesn't always work for dates - WHY?

Dickison

Board Regular
Joined
Jun 12, 2002
Messages
75
I download spreadsheets from a web site that have dates in this format:

Oct 1 2003 12:00AM

On some of the spreadsheets I can use the text-to-column to convert the text dates to Excel dates, but on other spreadsheets it refuses to work. I noticed that sometimes the spreadsheets come down as html rather than xls files, but they still look like xls files. I thought that might be the problem, so I saved the file as an xls file, but I still can't convert to dates using text to column. I then copied the columns with the dates to a new spreadsheet. They still won't convert. What's going on that could make the spreadsheet behave this way and how can I get the dates converted using text to column. I know I can use formulas, but because I have to do this frequently, I'd like to know why I can't convert and how to fix it.

Thanks.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Dickison:

Please look at the following simulation. I did not have much luck using formulas in native Excel, but I could convert the entry in cell A1 to date entry in cell B1 ...
y030919h2.xls
ABCD
1Oct1200312:00AMOct-01-03
Sheet10


using the following code ...
Code:
[b1] = Format([a1], "mmm-dd-yy")
I hope this helps. If I have misunderstood the question -- my apologies!
 
Upvote 0
If I understand your response, I am to make a macro using your formula. Macros are still untested by me, so that may work, but what I'm looking for is the reason a spreadsheet won't convert text to columns sometimes and will other times with the exact same kind of data. I suspect there is a setting somewhere that I need to change. For example, one problem I had was because the font was unicode. When I changed to a non-unicode font things worked as expected. On the spreadsheet that I had that wouldn't work, it had unicode. I changed it but that didn't fix the text to column problem. Then I noticed that the file was in html format rather than xls. I changed to xls and that didn't fix it either. This is the type of glitch it is I suspect because it works fine other times. I even open a brand new spreadsheet and then copy the data over, but that doesn't fix it either. The problem isn't just how to do it since I know how to do the formulas to convert and I can save as a text file and re-import to fix it. But those techniques are work-arounds for the basic problem of why it's not converting in the first place. That's what I need to know so I can directly fix it in the future.
 
Upvote 0
The reason Text to Columns fails to convert your dates is because they aren't in a recognized date format. If your dates had a comma after the day and a space before AM/PM Text to Columns would work just fine. You can use this formula will convert your dates...
Book1
ABCDE
1Oct1200312:00AM10/1/0312:00AM
2
3
4
Sheet1
 
Upvote 0
Edit : Just saw Master Mark_W's post -- so hopefully this settles it!

Hi Dickinson:

I played around a bit with various possible entries -- I could utilize DATA_Text_to_Columns with just date entries that appear as OCT 1 2003; but I could not suuccessfully utilize DATA_Text_to_Columns with entries that included time that appeare as OCT 1 2003 12:00 AM

The macro that I proposed ...
Code:
[b1] = Format([a1], "mmm-dd-yy")
did work for me in my limited testing of various combinations that i tried.

Please do post back to tell us what worked and how you finally resolved it!
 
Upvote 0
Hi Mark:

In the following illustration ...
y030919h2.xls
ABCD
18OCT1200312:00AMOCT1200312:00AM
19OCT1200312:00AMOCT1200312:00AM
20OCT1,200312:00AM10/01/20030:00
21OCT1200301-Oct-03
Sheet10


I used DATA_Text_to_Columns to convert entries in column A and write the resulting true Date_Time entries in the corresponding row in column B. Entries in cells A18 and A19 did not convert because as you pointed out that these are not in an Excel acceptable data format. However, the entry in cell A21 which is also not in acceptable Excel Date_Time format did get converted -- Any Ideas on this one?
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

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