Solved

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

Posted on 2011-09-28
5
694 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

809 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