June 18, 2009 at 9:59 am
In my SSIS package, I have a source file .csv. The dates in this file are string ie. 3/14/09, 12/4/09. I'm transferring into a table that defines this date as char(10).
In my transformation property of my DTS, I used have the inputformat and outputformat defined as type=string and value=mm/dd/yyyy. When the data moved from the csv into the table, the date on the table would be 03/14/2009 and 12/04/2009.
How do I accomplish this in SSIS? Do I do this with Derived Column?
June 18, 2009 at 10:28 am
June 18, 2009 at 10:33 am
The app will only read it as char.
June 18, 2009 at 12:12 pm
I figured out how to do it in sql. How do you do it in SSIS derived columns.
Input is 3/1/2009 Output is 03/01/2009
SELECT
CAST( RIGHT(POWER(10,2) + CAST(CONVERT(CHAR(2),DATEPART(M, xDate),101) AS INT), 2) AS CHAR(2))
+ '/' +
CAST( RIGHT(POWER(10,2) + CAST(CONVERT(CHAR(2),DATEPART(D, xDate),101) AS INT), 2) AS CHAR(2))
+ '/' +
CAST( RIGHT(POWER(10,4) + CAST(CONVERT(CHAR(4),DATEPART(YYYY, xDate),101) AS INT), 4) AS CHAR(4))
FROM XYZ
June 18, 2009 at 3:40 pm
Try this:
Replace @[User::xDate] in the following expression with your column name ( i m using a variable just for example)
RIGHT("00" + (DT_WSTR, 10) DATEPART( "mm", (DT_DBDATE) @[User::xDate] ) ,2) + "/" + RIGHT("00" + (DT_WSTR, 10) DATEPART( "dd", (DT_DBDATE) @[User::xDate] ) ,2) + "/" + (DT_WSTR, 10) DATEPART( "yyyy", (DT_DBDATE) @[User::xDate] )
i am assuming the datatype of your coulm xDate is string type.
HTH
June 19, 2009 at 12:45 pm
I do not know how to do this. I took your string. Replaced the text User::xDate with xDate and placed it in as an expression in my derived column process. The derived column name is xDate (comes from the source table; passing the value to a destination table).
RIGHT("00" + (DT_WSTR, 10) DATEPART( "mm", (DT_DBDATE) @[xDate] ) ,2) + "/" + RIGHT("00" + (DT_WSTR, 10) DATEPART( "dd", (DT_DBDATE) @[xDate] ) ,2) + "/" + (DT_WSTR, 10) DATEPART( "yyyy", (DT_DBDATE) @[xDate] )
June 19, 2009 at 1:09 pm
Thank you very much. This expression did work.
In the expression, instead of using xDate, I needed to use Column 2.
RIGHT("00" + (DT_WSTR, 10) DATEPART( "mm", (DT_DBDATE) [Column 2] ) ,2) + "/" +
RIGHT("00" + (DT_WSTR, 10) DATEPART( "dd", (DT_DBDATE) [Column 2] ) ,2) + "/" +
RIGHT("0000" + (DT_WSTR, 10) DATEPART( "yyyy", (DT_DBDATE) [Column 2] ) ,4)
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply