Sinoy Devassy
Sinoy Devassy

Reputation: 574

convert date format from 'DD\MM\YYYY' to 'MM\DD\YYYY' in SSIS

I am trying to insert a date value in the format of mm\dd\yyyy to SQL Server. In my source .csv file its in the format dd\mm\YYYY. Is it possible to insert a datefield to SQL Server in this format?

Thanks...

Upvotes: 0

Views: 10500

Answers (2)

Clint Good
Clint Good

Reputation: 850

In the dataflow add a derived column transformation. Create a new derived column and change its expression to

(DT_DBTIMESTAMP)(SUBSTRING(TextDate,7,4) + "-" + 
    SUBSTRING(TextDate,1,2) + "-" + SUBSTRING(TextDate,4,2))

You can then map this column to your sql server destination column

Upvotes: 3

Jean-Charles
Jean-Charles

Reputation: 1720

Use a dataflow transformation Data conversion and choose DT_DATE as output type.

The string in input (from your Excel file) will be convert to date object (if your table column is not typed as date).

Otherwise, you can add a dataflow transformation script component to parse your string and transform it as demanded using C#...

Upvotes: 0

Related Questions