简体   繁体   中英

Data type conversion in MD5 either SSIS or C#

I am converting some packages from Informatica to SSIS and the source is MySQL and the destination is AWS Redshift Problem is that the informatica has an MD5 expression containing char, varchar, MMDDYY and MMDDYY HHMMSS as part of the expression for hashing which is used for incremental load

My problem is that when I write a C# script I am unable to convert the dates properly.

And I am unable to use an OLEDB or Execute SQL task as it is isn't compatible with Redshift

So am stuck. Any tip will be appreciated

Thanks

If you are looking to parse MMDDYY HHMMSS and MMDDYY date values to date time using c#, you can simply use DateTime.ParseExact() function to do that. Assuming the outColumn is the output column of type DT_DATE :

Row.outColumn = DateTime.ParseExact(Row.DateColumn,"MMddyy",System.Globalization.CultureInfo.InvariantCulture);

Or

Row.outColumn = DateTime.ParseExact(Row.DateColumn,"MMddyy HHmmss",System.Globalization.CultureInfo.InvariantCulture);

Or you can define an array of string that contains all formats and use it within this function:

string[] formats = {"MMddyy","MMddyy HHmmss"};
Row.outColumn = DateTime.ParseExact(Row.DateColumn,formats,System.Globalization.CultureInfo.InvariantCulture);

Update 1

Based on your comments, you need to use:

Row.DateColumn.ToString("MMddyy")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM