Solved

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

Posted on 2011-09-28
5
686 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:
huslayer 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Help - 12 42
Auditing in Azure SQL Database 3 28
MSSQL Frequency of Years From Days Field 2 16
SQL 2008 Conversion failed 7 0
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

747 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

13 Experts available now in Live!

Get 1:1 Help Now