I am trying to convert a string into Date using Derived column and I am using Flat File Source.
I read bunch of articles on stackoverflow and followed the same steps but I am unable to convert my string into date format.
Here is the string
Tue Nov 25 17:32:03 EST 2008
And I want to show it like
2008-nov-25
I tried using the following code
(DT_DBDATE)(SUBSTRING(dateCreated,24,4) + "-" + SUBSTRING(dateCreated,4,3) + "-" + SUBSTRING(dateCreated,8,2))
I also tried to use
(DT_DATE)(SUBSTRING(dateCreated,24,4) + "-" + SUBSTRING(dateCreated,4,3) + "-" + SUBSTRING(dateCreated,8,2))
(DT_DBTIMESTAMP)(SUBSTRING(dateCreated,24,4) + "-" + SUBSTRING(dateCreated,4,3) + "-" + SUBSTRING(dateCreated,8,2))
Is this the correct way to convert the string into date format?
I dont think its possible to display the in the format of yyyy-mon-dd as per BOL. I checked your expression and after minor changes, was able to make it to work. You cannot typecast your string into a string again (You want month name in your output). Even if you were to use the DATEPART function, it would again amount to concatenating different parts into a string.
The expression that works with your input is as follows (replace @dateCreated with whatever you want to).