dbTalk Databases Forums  

Converting a date string to a date field

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Converting a date string to a date field in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Cazian
 
Posts: n/a

Default Converting a date string to a date field - 12-20-2004 , 01:43 PM






I have a txt file that contains the date in a string format. I import this in
directly and it comes up a vchar instead of a date field. I need to convert
it to a date so I can do an index on it. I don't know if it is possible to do
in the DTS or if I should leave it how it is and then use a conversion in the
view. I see different things about VB on the board but I don't yet understand
how to implement that either in the DTS. I see that I can do a Cdate in VB
but how I put that into the correct column and have everything else come into
the table is beyond me at this point. Any advice would be gladly appreciated.

Thanks,
--


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Converting a date string to a date field - 12-20-2004 , 02:32 PM






What happens when you try to simply pump the "Text" Date into a proper
DateTime field?

There is no cute SQL that you can perform on the source before it gets to
the transformations because text files are about as flexible as me in a yoga
class.

You would have to perform manipulation if the above does not work in an
Active Script transform

Have a look here

Formatting Character Data into Datetime fields
(http://www.sqldts.com/default.aspx?249)

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


"Cazian" <Cazian (AT) discussions (DOT) microsoft.com> wrote

Quote:
I have a txt file that contains the date in a string format. I import this
in
directly and it comes up a vchar instead of a date field. I need to
convert
it to a date so I can do an index on it. I don't know if it is possible to
do
in the DTS or if I should leave it how it is and then use a conversion in
the
view. I see different things about VB on the board but I don't yet
understand
how to implement that either in the DTS. I see that I can do a Cdate in VB
but how I put that into the correct column and have everything else come
into
the table is beyond me at this point. Any advice would be gladly
appreciated.

Thanks,
--




Reply With Quote
  #3  
Old   
Cazian
 
Posts: n/a

Default Re: Converting a date string to a date field - 12-20-2004 , 04:13 PM



It does error out unfortunately. So in that case I will have to keep to how
it is and create a view off of it instead that does the conversion somehow.
So I guess I will see if I can figure out how to do that now instead. Thanks
for the quick reply.

Cazian


"Allan Mitchell" wrote:

Quote:
What happens when you try to simply pump the "Text" Date into a proper
DateTime field?

There is no cute SQL that you can perform on the source before it gets to
the transformations because text files are about as flexible as me in a yoga
class.

You would have to perform manipulation if the above does not work in an
Active Script transform

Have a look here

Formatting Character Data into Datetime fields
(http://www.sqldts.com/default.aspx?249)

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


"Cazian" <Cazian (AT) discussions (DOT) microsoft.com> wrote in message
news:9F730F80-2E85-4526-B432-6D18AC784203 (AT) microsoft (DOT) com...
I have a txt file that contains the date in a string format. I import this
in
directly and it comes up a vchar instead of a date field. I need to
convert
it to a date so I can do an index on it. I don't know if it is possible to
do
in the DTS or if I should leave it how it is and then use a conversion in
the
view. I see different things about VB on the board but I don't yet
understand
how to implement that either in the DTS. I see that I can do a Cdate in VB
but how I put that into the correct column and have everything else come
into
the table is beyond me at this point. Any advice would be gladly
appreciated.

Thanks,
--





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.