On Mon, 8 Dec 2003 11:22:12 -0800, "Fred Jones" wrote:
Quote:
I'm trying to use VBScript in DTS to convert a time
string, with tenths of a second, to a sql 2k datetime
value. The standard ISO format of "yyyy/mm/dd hh:mm:ss
AM/PM" doesn't seem to support fractions of a second. Is
there a way in DTS Active-X script to assign a string
value like "2003-11-07 17:23:33.4" to a SQL datetime
column? |
It would be nice if you could just assign the data in its original type
(most likely Variant/Date) to the destination field, but there is a
problem in the conversion of dates from datetime in ADO into Variant and
vice versa:
http://support.microsoft.com/default...EN-US;Q297463&
So, you'll have to use a string. To preserve the milliseconds, append
them to the time portion of your string in the same way that SQL Server
presents them - .nnn
Now the problem is, I don't see a way to extract the milliseconds from a
Date field in VBScript.
Your best bets are:
* forget using VBScript to transform this field, just use a DataPump
transform
* convert the data to a string type in your source database, and
possibly also your target database, and handle the conversion back to
datetime in SQL Server
If you are pulling the data from a system that doesn't allow you to
convert the field to a string, then you are possibly screwed. Either
that, or you need an interim step that operates outside DTS.
Oh, actually, there might be a way to get the milliseconds from the
source field (I'm not untyping what I just typed though!):
http://support.microsoft.com/default...EN-US;Q327080&
That code is VB, not VBScript, so might not help. Also, I'm still not
sure whether you will get away with it at the target database side; you
might need to pump the data into a table with the field in question
defined as a char field, as I think the Variant to datetime conversions
might happen within ADO.
cheers,
Ross.
--
Ross McKay, WebAware Pty Ltd
"The lawn could stand another mowing; funny, I don't even care"
- Elvis Costello