Solved

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

Posted on 2011-09-28
5
706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

630 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