SSIS Derived Column
I have a derived column that returns todays date as DDMMYYYY However when it loads the data to the output file it is dropping the first 0. This is the expression RIGHT("0" + (DT_WSTR,2)DAY(DATEADD("dd",0,GETDATE())),2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("dd",-1,GETDATE())),2) + (DT_WSTR,4)YEAR(DATEADD("dd",-1,GETDATE())) This would return the value 4102011 Whereas I want 04102011 Anybody help?
October 3rd, 2011 10:05pm

Looks like the probelm is not with my expression but with the loading of the data into excel. excel drops the leading 0. Any ideas how I can get around this?
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 10:25pm

Hi, What is the data type you are using for the derived column? Excel would leave the leading zeros if the datatype in excel is Number however it'd retain leading "0" if it's a text. I tried to check your scenario using data type as Unicode String (DT_WSTR) and it worked for me. You can try it if it works for you. HTH. Regards, SantoshIt feels great if you give us points for helpful posts. :)
October 3rd, 2011 11:47pm

right click on excel source, and choose advanced editor, then go to input & output tab, under output, choose your column, and change datatype to DT_STR or DT_WSTR. let us know if this helpedhttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
October 4th, 2011 1:31am

You can add a leading single quote "'" + RIGHT("0" + (DT_WSTR,2)DAY(DATEADD("dd",0,GETDATE())),2) + RIGHT("0" + (DT_WSTR,2)MONTH(DATEADD("dd",-1,GETDATE())),2) + (DT_WSTR,4)YEAR(DATEADD("dd",-1,GETDATE()))
October 4th, 2011 2:15am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics