How can I convert string (YYMMDD) to datetime using derived column transformation?

后端 未结 2 1877
一个人的身影
一个人的身影 2021-02-16 00:03

I have an input text file, which consists of few columns namely TransactionID, receiveddt, description etc. The recieveddt co

2条回答
  •  温柔的废话
    2021-02-16 00:53

    Try this:

    (DT_DATE)("20" + SUBSTRING(receivedt,1,2) + "-" + SUBSTRING(receivedt,3,2) + "-" + SUBSTRING(receivedt,5,2))
    

    Note that this conversion assumes that all dates are in the current century. If you have dates in the previous century, you should add a condition to check for that.

    Also define an error path for your derived column transformation to catch misformatted dates. You can then, for example, give them a default value.

提交回复
热议问题