SSIS 2005:有效月份缩写

时间:2017-04-05 21:07:33

标签: excel vb.net windows date ssis

我从XL导入文本/字符串日期并在vb脚本组件中进行操作。

有效月份缩写列表是Windows事物,XL事物,VB事物,SSIS事物吗?有没有办法修改此列表...具体来说,添加 9月作为 9月的有效缩写?

有些人喜欢使用 9月(而不是 9月 9月,但 9月会引发错误转换为约会时。

我希望能够设置我的系统,以便 2007年9月 2007年9月将转换为 2007-09-01 无需任何错误,无需任何时候我需要转换为日期数据类型。

感谢任何人提供的任何帮助,

CTB

1 个答案:

答案 0 :(得分:0)

我不知道任何替代月缩写的来源,但至少对于9月和9月提供的样本,美妙的是你只需要前3个字符匹配才能成功,所以在你的脚本中,使用子串/左函数调用仅回退月份字段的前三个字符。

C#about

if (!row.Column1_IsNull)
{
    // Split on white spaces
    var pieces = Column1.Split();

    // Variable for our date
    DateTime cleanDate = DateTime.MinValue;

    // Depending on how dirty the data, you might need a harder scrubber
    // Assumes the first element is a month name of varying brevity
    // the second element is the year
    // You might also need to patch in the 1 for the day of the month
    string clean = string.Format("{} {}", pieces[0].Left(3), pieces[1]);

    if (DateTime.TryParse(clean, cleanDate))
    {
        row.CleanDate = cleanDate;
    }
    else
    {
        // Error handling logic
        row.CleanDate_IsNull = true;
    }

}