use convert colmn task instead of derived.
also make sure the column you are trying to convert is convertable (scrub data)
Main Topics
Browse All TopicsHi
Having real problems getting a string held in source csv file into a datetime SQL table using SSIS Derived Column Transformation. The relevant csv column holds date information in the form:
2004-05-31 00:00:00.000
I think my data is in the right format to be read easily, although I could be wrong.
In the Edit section of the Derived Column component I currently have the following:
Derived Col Name Derived Col Expression Data type
Column 0 <add as new column> (DT_DATE)([FlatFileOutputC
This doesnt work, nor do several attempts using DT_TIMESTAMP and DT_TIMESTAMP2, as I always get the error:
Error: An error occurred while attempting to perform a type cast.
Could someone help clarify the format of the date string that needs to be generated by the Expression, and also suggest a suitable Expression that would work?
thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In response to acperkins suggestion:
Removing the brackets doesnt make any difference I'm afraid. I have also tried:
(DT_DATE)(TRIM([FlatFileOu
and
(DT_DATE)(FlatFileOutputCo
and
(DT_DBDATE)(FlatFileOutput
and
(DT_DBTIMESTAMP)(FlatFileO
and
(DT_DBTIMESTAMP2,3)(FlatFi
I am coming to the conclusion that my date format is not right. It looks like this:
2004-05-31 00:00:00.000
and I have read that there are other formats eg 2004-05-31T00:00:00.000 that may be required. If we can agree on what form is acceptable, I can work to create it in the expression using substrings etc.
Can anyone clarify the format required to get us started please?
In response to Hwkranger:
I am working on my SSIS project within Visual Studio 2008 and do not see a 'Converted Column' task in the toolbar. The most relevant-sounding Data Flow Transformations include:
Copy Column
Data Conversion
Derived Column
Export Column
Import Column
or as suggested by VBClassicGuy:
Script Component
Could you clarify which one you mean? Thanks
In response to VBClassicGuy:
Thanks for this different angle, which I have had a quick go at but not succeeded with just yet. I am focusing on the Derived Column approach as I believe this was the component designed to help me with this type of issue, but will use the Script Task approach if necessary.
I thought I was reasonably ok with VB.NET but in fact I struggled to apply your one-liner to my problem, mostly because I am not at all familiar with pipeline-related objects. Could you provide just a little more of the code, and specify where I should place it within the auto-generated code, knowing that:
1. My source component is called 'Flat File Source'
2. The column I am trying to convert has been named 'FlatFileOutputColumn0' with data type DT_STR
Apols for effectively requesting spoon-feeding here, but if you show me this one, I will quickly be up and running with the Script Task and will be able to use it many times over.
Thanks
Sorry for the delay in responding on this one, the reason being is I havent completely solved my problem yet.
However, for those interested in solving a similar problem, I have found that my data had some problems so I am guessing that all of the suggestions received would be ok to solve my issue if this had not been the case.
To the respondents, I thank you very much for your input and have divided the points evenly based on the number of suggestions received - trust you find this ok (especially acperkins who I seem to have upset - apols).
>>To the respondents, I thank you very much for your input and have divided the points evenly based on the number of suggestions received - trust you find this ok (especially acperkins who I seem to have upset - apols).<<
Not at all. I was just following the EE Guidelines as to how questions should be closed.
Business Accounts
Answer for Membership
by: qprjohn121Posted on 2009-10-09 at 08:43:25ID: 25536122
I should perhaps add that 'FlatFileOutputColumn 0' is the name defined within the Flat File Source component relating to the csv date column, and is of data type DT_STR.