[英]Data type conversion in MD5 either SSIS or C#
我正在將某些軟件包從Informatica轉換為SSIS,源是MySQL,目標是AWS Redshift問題是informatica具有MD5表達式,其中包含char,varchar, MMDDYY
和MMDDYY HHMMSS
作為哈希表達式的一部分,用於增量加載
我的問題是,當我編寫C#腳本時,無法正確轉換日期。
我無法使用OLEDB或執行SQL任務,因為它與Redshift不兼容
所以被困住了。 任何提示將不勝感激
謝謝
如果要使用c#將MMDDYY HHMMSS
和MMDDYY
日期值解析為日期時間,則只需使用DateTime.ParseExact()
函數即可。 假設outColumn
是DT_DATE
類型的輸出列:
Row.outColumn = DateTime.ParseExact(Row.DateColumn,"MMddyy",System.Globalization.CultureInfo.InvariantCulture);
要么
Row.outColumn = DateTime.ParseExact(Row.DateColumn,"MMddyy HHmmss",System.Globalization.CultureInfo.InvariantCulture);
或者,您可以定義一個包含所有格式的字符串數組,並在此函數中使用它:
string[] formats = {"MMddyy","MMddyy HHmmss"};
Row.outColumn = DateTime.ParseExact(Row.DateColumn,formats,System.Globalization.CultureInfo.InvariantCulture);
根據您的評論,您需要使用:
Row.DateColumn.ToString("MMddyy")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.