Changing text to date format

G

Guest

Hello
I have imported a text file to an excel sheet and the date fields have been formated as text. I have not been able to convert the cells back to date format. When I do, the data turns into ###########

Any ideas as to why this is happening and what I can do to change the data to date?
 
A

Andy B

Hi

One possibility - depending on what is actually in your cells.
Copy a blank unused cell.
Select your range and Edit / Paste Special / Add

--
Andy.


Ron B said:
Hello,
I have imported a text file to an excel sheet and the date fields have
been formated as text. I have not been able to convert the cells back to
date format. When I do, the data turns into ###########.
Any ideas as to why this is happening and what I can do to change the data
to date?
 
D

daniels012

I do this sort of thing all the time!!

Insert 2 rows next to the cell that has the TEXT date.
Let's just say Cell B3
Enter this formula into cell C3
=MONTH(DATEVALUE(B3))&"/"&DAY(DATEVALUE(B3))&"/"&YEAR(DATEVALUE(B3))
You now want to copy the contents of cell C3.
Then goto Cell D3 and Paste Special (Values Only)
In cell D3 is your converted date. Once done you can delete cells B
and C3.

Hope this Helps
Michae
 
G

Guest

Hi Andy

I copied a blank cell and pasted it to the top of the column and formatted it to date. I then copied and pasted data from one of the effected cells to the blank cell. It repasted the data as text. When I went in to change it to date, it had no effect at all

Ron
 
A

Andy B

Like I said, it depends on what, exactly, is in your cell to start with. Is
it a 'date'? Does it have slashes or dots? Does it look like a date? What
does it say in the formula bar when it's selected?

--
Andy.


Ron B said:
Hi Andy,

I copied a blank cell and pasted it to the top of the column and formatted
it to date. I then copied and pasted data from one of the effected cells to
the blank cell. It repasted the data as text. When I went in to change it
to date, it had no effect at all.
 
G

Guest

It appears as it is text typed as year month day. The value in the field looks like 20030225

----- Andy B wrote: ----

Like I said, it depends on what, exactly, is in your cell to start with. I
it a 'date'? Does it have slashes or dots? Does it look like a date? Wha
does it say in the formula bar when it's selected

--
Andy


Ron B said:
it to date. I then copied and pasted data from one of the effected cells t
the blank cell. It repasted the data as text. When I went in to change i
to date, it had no effect at all
 
D

daniels012

If this is your value in Cell C4:
20030225
Then Put this formula in Cell D4:
=MID(C4,5,2)&"/"&RIGHT(C4,2)&"/"&LEFT(C4,4)
You now want to copy the contents of cell C3.
Then goto Cell D4 and Paste Special (Values Only)
In cell E4 is your converted date. Once done you can delete cells C
and D4.


Michae
 
P

Peo Sjoblom

Or faster, select the column, do data>text to columns, click next twice and
under column data format select date and YMD, click finish

--


For everyone's benefit keep the discussion in the newsgroup.

Regards,

Peo Sjoblom
 
G

Guest

I don't know if I should have started a new thread for this question, but in fact for some reason I can't get any response by clicking on 'New' anyway, so I don't have much choice.

I have a sheet with 1600 dates in the form, for example '1-1-1997' and I must change them to ISO format '1997-01-01'. At present, the cells containing these dates are formatted as 'General', becuase they were imported (by someone else, in another country) from a database.

I tried adding three columns to the right and then 'text to columns' but that produced weird effects, including corruption of existing columns to the right of the three new ones.

In view of the number of conversions needed, any solution need not be of the utmost simplicity, but it must work reliably, becuase checking all 1600 for correct conversion would be tedious and maybe inaccurate.
 
D

Dave Peterson

I think you have to decide what's really in those cells first.

If the values were entered as text, then changing the format of the cells to
General will still leave the value as text. But with the next change (even just
F2|Enter), excel will see it as a date.

So the first thing I'd do is try to reenter those values so that excel could
interpret them as dates.

Ctrl-a (twice in xl2003) to select all the cells.
edit|replace
what: - (hyphen)
with: - (hyphen)
replace all.

Depending on your computer's date format and the values in the cells, you may be
almost done.

I'd format a few of the cells using an unambiguous date format: dd-mmm-yyyy
(for example).

Then you can see if values got converted to dates correctly.

If they did, format them the way you want (yyyy-mm-dd).

But if it tried to convert 12-7-1997 into December 7, 1997 and you wanted July
12, 1997, you have more work to do.

One way that you could try is to convert your pc's short date settings to the
format that you want.

close excel
windows start button|settings|control panel|regional settings applet
Date Tab (fix that short date setting)
(I use win98, so your steps might be slightly different.)

Then back to excel and try it out again.

If it worked ok, then close excel and change your regional settings back to the
way you like them. (I didn't actually have to close excel, but it couldn't
hurt!)


==============
Another way if your data is laid out nicely in columns is to select a column
(it's one column at a time).
Then data|text to columns
choose delimited (uncheck everything)
tell excel that the field should be mdy or dmy
This is the "format" of the current values--not what you want.
and finish up by putting it in the same location.
(You can change the format to what you really want later.)

Then do the next column, and the next, and the next....
 
G

Guest

You could download the third party tool: AddinTools Assist from
http://www.addintools.com. It includes several functions. One of these
functions is convert data of cells to text/number/date-time type.
It can convert data of all formats to text type.
It can recognize these formats as following and convert to date-time type:
2003.1.2, 2003.1.2 11:12:13:14PM, 2003-1-2, 2003-1-2 11:12:13.14PM,
20030102, 20030102 11:12:13:14PM, and locale format on your computer, and so
on …
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top