Convert sting to datetime

How can I convert it to 

"  2015/07/31" to "31/07/2015"

By using derived column.

I want to TRIM the date field.

I am using this expression:

(DT_DBTIMESTAMP)(SUBSTRING(TRIM([Start Date]),1,4) + "/" + SUBSTRING(TRIM([Start Date]),5,2) + "/" + SUBSTRING(TRIM([Start Date]),7,2))

in Derived column

But giving error :

[Derived Column 1 [5452]] Error: The "component "Derived Column 1" (5452)" failed because error code 0xC0049064 occurred, and the error row disposition on "output column "Start Date" (5650)" specifies failure on error. 

An error occurred on the specified object of the specified component. 

[DTS.Pipeline] Error: The ProcessInput method on component "Derived Column 1" (5452) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. 

The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. 


  • Edited by kalsubu Tuesday, July 14, 2015 10:28 AM
July 14th, 2015 10:17am

If you want to convert string "  2015/07/31" to 2015-07-31 00:00:00.000 datetime format, please refer to the following expression:
(DT_DBTIMESTAMP)(TRIM([Start Date]))

but this expression is not working when having NULL values.

Please suggest.

Free Windows Admin Tool Kit Click here and download it now
July 15th, 2015 7:45am

Hi kalsubu,

After testing the same issue in my environment, the same expression works very well with NULL values. The following screenshot is for your reference:

Please post more details about the issue, then we can make further analysis.

Thanks,
Katherine Xiong

July 15th, 2015 10:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics