在派生列中将字符串转换为日期时间时出错

Getting error while converting a string to datetime in derived column

我的 table 中有一个名为 Paid_Date 的列,它有一种不正确的日期值,在日期和时间值之间有一个冒号(例如 '04MAY2015:00:00:00')。

为了排除那个冒号,我使用了表达式

((DT_DBTIMESTAMP)SUBSTRING(PAID_DATE,1,9))

在我的派生列转换中。

当我尝试 运行 时,出现以下错误。

Expression used in my trasformation: (DT_DBTIMESTAMP)SUBSTRING(PAID_DATE,1,9)
Source column data type : varchar             
Source column Value: 04MAY2015:00:00:00
Error: [Derived Column [1613]] Error: An error occurred while attempting to perform a type cast.
Detailed Error:[Derived Column [1613]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  
The "component "Derived Column" (1613)" failed because error code 0xC0049064 occurred, 
and the error row disposition on "output column "PaidDate" (1954)" specifies failure on error. 
An error occurred on the specified object of the specified component.  
There may be error messages posted before this with more information about the failure.

我什至尝试使用以下表达式:

(DT_DBTIMESTAMP)((DT_STR,50,1252)SUBSTRING(PAID_DATE,1,9))

SUBSTRING操作后不能转换字符串吗?

将字符串转换为 DT_DBDATETIME must use a specific string format:

yyyy-mm-dd hh:mm:ss[.fff]

您需要先将字符串转换为标准格式,然后才能进行转换。

提取月份,使用查找转换或 nested ternary operators 将其更改为两位数字字符串,然后将结果格式化为可以转换为 DT_DBDATETIME.[=13= 的字符串]