Home > Ask the SQL Server Experts > Michael Hotek Questions & Answers > Getting type mismatch error converting string to date
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Getting type mismatch error converting string to date

Michael Hotek EXPERT RESPONSE FROM: Michael Hotek

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 09 August 2004
I am using a DTS package to load a table from a text file. One of the transformations involves transforming a string (in the format of mm/dd/yyyy) into a datetime field in the same format (mm/dd/yyyy). Since the source field field is character and the destination field is datetime, I could not of course simply do a copy transformation. Neither would SQL Server allow me to do a simple datetime transformation. As a result, I have been experimenting with trying an Active X transformation using the CDate() function in an effort to convert the string to a date. The only problem is that I keep getting a Cdate type mismatch error, and I don't know how to resolve it. Currently this is how the Active X transformation looks:
Function Main()
   DTSDestination("Date")=CDate        (DTSSource="Col011"))
   Main = DTSTransformStat_OK
End Function
Could you please shed some light on why I keep getting the type mismatch error and what I might try to correct it?

>
You should be able to simply use a convert function to convert the data. If there is an error generated, it is because one or more of the rows contains an invalid date.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Michael Hotek
Applying LDF file to MDF without turning it to .BAK first?
Procedure for finding last modified info?
Migrating poorly designed database to new, normalized one
Displaying decimal places in SQL Server 2000
Creating a DTS package
Extracting data without strings converted to strange characters
Money data type conversion issue using DTS
Any way to alias a call to functions?
Repairing corrupt MDF files
In-place versus side-by-side upgrade

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts