469,280 Members | 1,998 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

How to convert datetime from text/char to datetime

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

Similar topics

19 posts views Thread by Lauren Quantrell | last post: by
15 posts views Thread by Dan S | last post: by
11 posts views Thread by jguilford | last post: by
8 posts views Thread by Assimalyst | last post: by
17 posts views Thread by Terry Jolly | last post: by
1 post views Thread by Wes Peters | last post: by
4 posts views Thread by RP | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.