简体   繁体   English

MD5中的数据类型转换(SSIS或C#)

[英]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 我正在将某些软件包从Informatica转换为SSIS,源是MySQL,目标是AWS Redshift问题是informatica具有MD5表达式,其中包含char,varchar, MMDDYYMMDDYY HHMMSS作为哈希表达式的一部分,用于增量加载

My problem is that when I write a C# script I am unable to convert the dates properly. 我的问题是,当我编写C#脚本时,无法正确转换日期。

And I am unable to use an OLEDB or Execute SQL task as it is isn't compatible with Redshift 我无法使用OLEDB或执行SQL任务,因为它与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. 如果要使用c#将MMDDYY HHMMSSMMDDYY日期值解析为日期时间,则只需使用DateTime.ParseExact()函数即可。 Assuming the outColumn is the output column of type DT_DATE : 假设outColumnDT_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 更新1

Based on your comments, you need to use: 根据您的评论,您需要使用:

Row.DateColumn.ToString("MMddyy")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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