I have a serialized code, and from within this code there are numeric values which when parsed represent a date.
For example, 011756420176654
*Note* array index may be off
Substring(1,2) = 01
Substring(3,2) = 17
I'm trying to ignore the row, without replacing the original row. I have a derived column, and am doing this in the column.
(dt_date)(Substring([My Code], 1, 2) + "-" + Substring([My Code], 3, 2) + (dt_str,10,1252)datepart("year",getdate()))
My intention here is to configure my error output to ignore the [My Code] field if the "TryParse"-logic in the derived column fails. I know if I were passing the derived column, that selecting ignore on the configuration will pass null, but the problem is I'm trying to (on error) ignore the source row and pass that as null (ie [My Code]).
Once this hit's the database, another process consumes it and attempts to parse the dates. It will not fail on null values, so I want to validate that essentially "is date"-logic before allowing the record through, or setting it to null.
Edit: Per Keith's solution, I came to this. I was having issues accessing the output buffer, but after some MSDN on syntax I came up with the following which works perfectly.
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
DateTime dateValue;
string test = Row.ReceiptCode.Substring(0, 2) + "/" + Row.ReceiptCode.Substring(2, 2) + "/" + DateTime.Now.Year.ToString();
if (DateTime.TryParse(test, out dateValue) && Row.ReceiptCode.Length ==16)
{
Output0Buffer.AddRow();
Output0Buffer.EndDate = Row.EndDate;
Output0Buffer.Q10 = Row.Q10;
Output0Buffer.Q8 = Row.Q8;
Output0Buffer.ValidatedReceipt = Row.ReceiptCode;
}
else
{
Output1Buffer.AddRow();
Output1Buffer.EndDate = Row.EndDate;
Output1Buffer.Q10 = Row.Q10;
Output1Buffer.Q8 = Row.Q8;
Output1Buffer.Error = Row.ReceiptCode;
}
}