Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Date Help

Author  Topic 

Sonu619
Posting Yak Master

202 Posts

Posted - 2011-02-20 : 12:48:56
Hi guys,

I have source fields YY, MM
i want to add YY+MM
and my target field data type is "datetime" i am getting error. Please help me out how i can solve this issue in SSIS. I am using "Derived Column Transformation to add YY & MM. Thanks in advance.

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-20 : 13:03:54
Well, you would need to build YYYYMMDD for datetime.

In the derived column you need to build your desired result using an expression. If you are already combining YY and MM you can likely add '01' for the DD part you need.



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2011-02-20 : 13:20:21
Thanks for your prompt reply, if i understand right you are saying, in derived column use YY+MM_01 and mapped this field to target field?
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-20 : 13:29:54
It depends on the datatype of the source data, but a string in the ISO standard format of YYYYMMDD will not fail the transformation. Did you think you could just send year and month to the field and not error?

The underscore won't work, and you need a 4 digit year.

The expression might look like this, but I can't tell if your YY and MM are column names or variables.
(DT_WSTR,4) youryearcolumn
+ RIGHT("0" + (DT_WSTR,2)yourmonthcolumn, 2)
+ "01"

here is a good link that might help. http://www.sqlis.com/post/Expression-Date-Functions.aspx



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2011-02-21 : 21:26:33
dataguru, Thank you for your help.
Go to Top of Page
   

- Advertisement -