By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

How to convert datetime from text/char to datetime

P: n/a
Hi,

I have a text file that contains a date column. The text file will be
imported to database in SQL 2000 server. After to be imported, I want
to convert the date column to date type.

For ex. the text file look like

Name date
Smith 20003112
Jennifer 19991506

It would be converted date column to ydm database in SQL 2000 server.
In the table it should look like this

Name Date
Smith 2000.31.12
Jennifer 1999.15.06

Thanks in advance

- Loi -
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Loi,

If you want to store the data as type datetime, it will not "look like"
anything in the table. However, you can make it look however you
want when you select the results. Date values are stored as bits, not
as formatted character strings. The yyyy.dd.mm format is not one of
the numbered formats to use with convert(), so you will need to select
your datetime value and use string functions to format it. Try this:

select convert(char(4),[date],112) + convert(char(5),[date],4) from
yourTable

Steve Kass
Drew University

Loi Tan Vo wrote:
Hi,

I have a text file that contains a date column. The text file will be
imported to database in SQL 2000 server. After to be imported, I want
to convert the date column to date type.

For ex. the text file look like

Name date
Smith 20003112
Jennifer 19991506

It would be converted date column to ydm database in SQL 2000 server.
In the table it should look like this

Name Date
Smith 2000.31.12
Jennifer 1999.15.06

Thanks in advance

- Loi -


Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.