Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-28
5
Medium Priority
?
709 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 400 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 600 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 1000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

715 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