Home » excel » sql – Convert Date from Excel Import

sql – Convert Date from Excel Import

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am working on automating some data that I receive from Germany. The Date format comes in as DD.MM.YYYY and I need it to be MM/DD/YYYY.

I am building an import package using SSIS and I added a derived column to change the date format.

I first tried to use

(DT_DATE) [CalendarDay]

but I keep getting an error at the Derived Column when I execute the package.

[Derived Column [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.
The "Derived Column" failed because error code 0xC0049064 occurred, and the error 
row disposition on "Derived Column.Outputs[Derived Column Output].Columns[Date]" 
specifies failure on error.

So I moved through the many examples in StackExchange (all that I could find at least) and was met with the same error or not the desired output.

Any suggestions.

How to&Answers:

1) Source :- Flat file use DT_date for Date column
2) Derived Column :- Replace this with using

SUBSTRING([Column 2],4,4) + “/” + SUBSTRING([Column 2],5,2) + “/” + SUBSTRING([Column 2],7,2)

and use DT_DATE IN Datatype

3) Destination :- Use datetime as datatype for date

Run it

Thanks!

Answer:

Try instead:

— Issue with date column… use DT_Date and then in derived column use substring to include

 // so date will become 2009/02/05 and then transfer data to destination... 

it will work out..

Thanks!

Nilesh

Answer:

I fixed the error by using the Substring Method that was provided by user3112708 and making an minor alteration to the numbering sequence.

SUBSTRING(CalendarDay,4,2) + "/" + SUBSTRING(CalendarDay,1,2) + "/" + 
SUBSTRING(CalendarDay,7,4)

Thank you every one for your help.