简体   繁体   中英

SSIS Check date format with conditional split

I have a flat file that with a "date" column. The problem is that date could come in as

01-Jan-16 or

01Jan2016

If I run this in a derived column

(DT_DBDATE)(SUBSTRING(bene_dob,1,2) + "-" + SUBSTRING(bene_dob,3,3) + "-" + SUBSTRING(bene_dob,7,4))

it handles the second date fine, but really screws up the first date.

I'm trying to deal with this thru a conditional split, but I'm not sure how to proceed.

How do I verify that date format in a conditional split?

Or if you have an alternative suggestion, I'm open to ideas.

Thanks

一种快速而肮脏的方法是对日期列进行规范化 ,因此将其除去不需要的字符(在这种情况下为“-”),然后应用派生的列表达式,如下所示:

(DT_DBDATE)(SUBSTRING(REPLACE(bene_dob, "-", ""),1,2) + "-" + SUBSTRING(REPLACE(bene_dob, "-", ""),3,3) + "-" + SUBSTRING(REPLACE(bene_dob, "-", ""),7,4))

Replace the dashes with an empty string before the derived column so that all rows will have the same format (01Jan2016). You'll also need to add the first 2 digits of the year if they are missing.

Or if you really want to use a conditional split, just test for the presence of the hyphen character and split based on whether it is in the string or not.

在进行进一步处理之前,我将所有日期格式转换为相同格式,可以通过sql或sis中的数据转换来完成。

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