How to convert string in format yyyyMMdd to date using SSIS expression?

ssis

Solution

As per Kyle Hale suggestion, below is my answer

SUBSTRING([DATE_DECISION_TO_REFER],1,4) + "-" +
SUBSTRING([DATE_DECISION_TO_REFER],5,2) + "-" + 
SUBSTRING([DATE_DECISION_TO_REFER],7,2)

To educate you so that you will never face this issue again, this is how expression works

 Get 4 characters from DATE_DECISION_TO_REFER starting at position 1, add a dash,
 get 2 characters from DATE_DECISION_TO_REFER starting at position 5, add a dash, 
 get 2 characters from DATE_DECISION_TO_REFER starting at position 7.

Hope this will help.

Problem

I have a date `20130131` in csv which I'm trying to convert to `2013-13-01` using Derived Column in SSIS. I have used this expression but it does not seem to work. (DT_DBTIMESTAMP)(SUBSTRING(DATE_DECISION_TO_REFER,1,2) + "-" + SUBSTRING(DATE_DECISION_TO_REFER,3,2) + "-" + SUBSTRING(DATE_DECISION_TO_REFER,5,2)) How do I rewrite this expression to produce the correct output with a value of data type `DT_DBTIMESTAMP`?

Original source