Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2005, 08:18 PM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert string to date

I am trying to convert a string in the form of "ddmmmyy" to
a date in a DTS tranformation(activex script) in SQL Server. I have tried CDate and
Replace methods but to no luck.Any suggestion.

Thanks

 
Old December 22nd, 2005, 08:47 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

I presume an example of your format is 15MAR05 as well as 01MAR05

To setup a test scenario I execute the following TSQL code
CREATE TABLE t1 (dateDDMMMYY char(7))

INSERT t1 VALUES ('15MAR05')
INSERT t1 VALUES ('01MAR05')
INSERT t1 VALUES ('15MAR99')
INSERT t1 VALUES ('01MAR99')

CREATE TABLE t2 (SQLDate DATETIME)

Then I created a DTS Package with Two Connections objects pointing to my the database where my source table is and then another where my destinationt able is. Then I setup a Transform Task

For the Transform between the two columns I select DATE Time String Transformation
In the Properties Source Date Format I put: ddMMMyy
In the Properties Dest Date Format I put: dddd, MMMM dd, yyyy hh:mm:ss.ffff tt

Then I ran it.
To Test I ran select * from t2

SQLDate
------------------------------------------------------
2005-03-15 00:00:00.000
2005-03-01 00:00:00.000
1999-03-15 00:00:00.000
1999-03-01 00:00:00.000


David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert string to Date rprasad012 ASP.NET 1.0 and 1.1 Basics 1 March 19th, 2008 07:07 AM
how to convert string to date tgopal Javascript 2 March 18th, 2008 03:33 AM
convert string to date collie SQL Server 2000 4 March 15th, 2007 03:50 PM
Convert Part of String to Date twsinc Access VBA 6 October 20th, 2004 03:31 PM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.