How to convert varchar column into timestamp format with Data Conversion(SSIS Data Flow Item)?

I am getting date column in the source file(.csv) like  20080727063005. I need to load this value into Sql Server table as Datetime data type column.(yyyy-mm-dd hh:mi:ss FORMAT)  Hope i can do it with Data Conversion . But i am new to SSIS. So can you please tell me how to solve this problem with Data conversion? or Is there  any other easy method please let me know.
Thanks in advance.
PKTGAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MohammedUCommented:
DECLARE @dt Varchar(30)

SET @dt =  '20080727063005'
 

SELECT CONVERT(datetime,
       LEFT(CAST(CAST(@dt as BigInt) as varchar(14)),8)+' '+
       SUBSTRING(CAST(CAST(@dt as BigInt) as varchar(14)),9,2)+':'+
       SUBSTRING(CAST(CAST(@dt as BigInt) as varchar(14)),11,2)+':'+
       SUBSTRING(CAST(CAST(@dt as BigInt) as varchar(14)),13,2)
       )
Anthony PerkinsCommented:
Or simply :)

Declare @Dat varchar(14)
Set @Dat = '20080727063005'

Select CONVERT(datetime, STUFF(STUFF(STUFF(STUFF(STUFF(@Dat, 5, 0, '-'), 8, 0, '-'), 11, 0, ' '), 14, 0, ':'), 17, 0, ':'), 120)
PKTGAuthor Commented:
Thanks for the feedback . I did it with below script
SUBSTRING(column0,1,4)+'-'+
SUBSTRING(column0,5,2)+'-'+
SUBSTRING(column0,7,2)+' '+
SUBSTRING(column0,9,2)+':'+
SUBSTRING(column0,11,2)+':'+
SUBSTRING(column0,13,2) as STRT_TMST  
Now i am in the situation to do it via SSIS. I can use this scrip in Exec SQL  task. But Can you please tell me is it possible to do with Data Conversion Task? Thanks.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

MohammedUCommented:
I believe you can...but I have not tested it...
Steve HoggITCommented:
Use the SSIS Transformation, Derived Column.
http://msdn.microsoft.com/en-us/library/ms141069.aspx
 With the derived column you use an expression to parse the string into a datetime string and declare it as a DT_DATE data type. The following screen shot shows the start.

derived-column.bmp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve HoggITCommented:
Here is the expression
SUBSTRING(DateString,1,4) + "/" + SUBSTRING(DateString,5,2) + "/" + SUBSTRING(DateString,7,2) + " " + SUBSTRING(DateString,9,2) + ":" + SUBSTRING(DateString,11,2) + ":" + SUBSTRING(DateString,13,2)
Here is the return values
DateString,DATE
20080727063005,2008/07/27 06:30:05
PKTGAuthor Commented:
I am converting flatfile datestring to another flat file with SSIS package. With drived column , i gave the below expression with DT_Date datatype.

SUBSTRING(DateString,1,4) + "-" + SUBSTRING(DateString,5,2) + "-" + SUBSTRING(DateString,7,2) + " " + SUBSTRING(DateString,9,2) + ":" + SUBSTRING(DateString,11,2) + ":" + SUBSTRING(DateString,13,2)  
I expect it will return datestring value like 2008-07-22 21:58:36  but it shows 7/22/2008 9:58:36 PM.
But I need to display like 2008-07-22 21:58:36  . Can you please advise me how to fix this? Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.