Solved

how to convert the date value of  string to dbtimestamp in ssis

Posted on 2011-09-28
5
689 Views
Last Modified: 2013-11-10
I need to convert the string value to db datetimestamp in ssis
The source value is "Fri Oct 10 10:53:13 2008" and i need to convert it to 10-OCT-08. How can i do that..
What expression do i need to write in ssis derived column.

Thanks
0
Comment
Question by:srionline2k6
5 Comments
 
LVL 6

Assisted Solution

by:dan_mason
dan_mason earned 100 total points
ID: 36720191
Below is an example of a table with the computed column. I have also included a computed column that converts it to a normal date datatype.
DECLARE @dateTest TABLE 
	(	TextDate varchar(40), 
		RealDate AS CAST(SUBSTRING(TextDate,5,7)+RIGHT(TextDate,4) as date),
		FormattedDate AS UPPER(REPLACE(CONVERT(varchar(9),CAST(SUBSTRING(TextDate,5,7)+RIGHT(TextDate,4) as date),6),' ','-')) 
	)
INSERT @dateTest (TextDate)
VALUES ('Fri Oct 10 10:53:13 2008')

SELECT * FROM @dateTest

Open in new window

0
 

Author Comment

by:srionline2k6
ID: 36720223
Thanks for the reply.
How I need to convert this in ssis .
0
 
LVL 21

Assisted Solution

by:Alpesh Patel
Alpesh Patel earned 150 total points
ID: 36812837
(DT_WSTR,4)YEAR(GETDATE()) + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2) +  RIGHT("0" + (DT_WSTR,2)DAY( GETDATE()), 2)

Please update appropriate for your use.

0
 

Author Comment

by:srionline2k6
ID: 36816537

Thanks for the response. But the thing is source value is not in dateformat. Its in string format

the Column  CreationDate has the  source value is in this format "Fri Oct 10 10:53:13 2008" which is in csv file.

I want the destination value to be like  "10-OCT-08" which needs  to be populated in Oracle table.

I tried both the solutions but that's not working.
I tried using the following if i assume that all the value would be of same  number for each row in that column

(DT_DBTIMESTAMP)(SUBSTRING([date string], 1, 4) + "-" SUBSTRING([date string], 5, 2) + "-" +
SUBSTRING([date string], 7, 2))

But i am getting typecast error. What might be the problem.
Could you please help me in this regard.
0
 
LVL 21

Accepted Solution

by:
Jason Yousef, MS earned 250 total points
ID: 36819146

Substring([date string],5,3) + "-" + Substring([date string]],9,2) + "-" + Right([date string],2)

Open in new window

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now