Text to Column doesn't always work for dates - WHY? :: MrExcel Message Board



 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Text to Column doesn't always work for dates - WHY?
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Dickison
Board Regular


Joined: 13 Jun 2002
Posts: 42
Location: Hawaii

Status: Offline

 Reply with quote  

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

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.

Post Sat Sep 20, 2003 2:08 am 
 View user's profile Send private message Send e-mail AIM Address MSN Messenger

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

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

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 ...

Microsoft Excel - y030919h2.xls___Running: xl97 : OS = Windows 98
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
1
Oct 1 2003 12:00AM Oct-01-03  
Sheet10 

[HtmlMaker 2.20] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


using the following code ...
code:

[b1] = Format([a1], "mmm-dd-yy")



I hope this helps. If I have misunderstood the question -- my apologies!
_________________
Regards!
Yogi Anand

Post Sat Sep 20, 2003 3:23 am 
 View user's profile Send private message

Dickison
Board Regular


Joined: 13 Jun 2002
Posts: 42
Location: Hawaii

Status: Offline

 Reply with quote  

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

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.

Post Mon Sep 22, 2003 7:26 am 
 View user's profile Send private message Send e-mail AIM Address MSN Messenger

Mark W.
MrExcel MVP


Joined: 11 Feb 2002
Posts: 7146
Location: Austin, Texas USA
Flag: Usa

Status: Offline

 Reply with quote  

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

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...

Microsoft Excel - Book1___Running: xl2002 XP : OS = Windows Windows 2000
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
E
1
Oct 1 2003 12:00AM 10/1/03 12:00 AM   
2
     
3
     
4
     
Sheet1 

[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

Post Mon Sep 22, 2003 2:42 pm 
 View user's profile Send private message

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

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

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!
_________________
Regards!
Yogi Anand

Post Mon Sep 22, 2003 3:49 pm 
 View user's profile Send private message

Yogi Anand
MrExcel MVP


Joined: 13 Mar 2002
Posts: 5749
Location: Michigan USA

Status: Offline

 Reply with quote  

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

Hi Mark:

In the following illustration ...

Microsoft Excel - y030919h2.xls___Running: xl97 : OS = Windows 98
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
=

A
B
C
D
18
OCT 1 2003 12:00AMOCT 1 2003 12:00AM  
19
OCT 1 2003 12:00 AMOCT 1 2003 12:00 AM  
20
OCT 1, 2003 12:00 AM10/01/2003 0:00  
21
OCT 1 200301-Oct-03  
Sheet10 

[HtmlMaker 2.20] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.


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?
_________________
Regards!
Yogi Anand

Post Mon Sep 22, 2003 4:06 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.