I have an SSIS package that imports data form an excel source to a SQL Server DB. The file has a column named [Client Date Of Birth]
that is USUALLY a valid date. I say usually because the data is entered by our client's agents and can be anything from 02/24/2017
to Feb 17
or even just 2017
. I actually need this data to come in as a string because we do partial comparison to these dates so data coming in as Feb 2017
is still technically okay.
The problem is SSIS automatically determines that this column is of [DT_DATE]
type. I try to change the DataType to [DT_WSTR]
in the External columns section of the Advanced Editor for the source, but when i click OK, SSIS automatically switches it back to [DT_DATE]
. How do I get SSIS to import this column as a string?
It should also be noted that this is an automatic process so I can't make any changes to the excel file itself because it will be replaced by a new file each week.
There are many ways to achieve this:
First way
[Client Date Of Birth]
as an Input Column[StrDOB]
with Datatype equal[DT_STR]
In the script write the following code (i assumed that you want the date format
yyyy-MM-dd HH:mm:ss
):Second Way
Use a Data Conversion Transformation component to achieve this. Just follow this MSDN links to get Help: