Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 ActiveX Script Transformation

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2006-11-14 : 07:05:49
Hi Am using activex script to copy data from the source to destination, one problem i have is with my date format, its in text format in the file and in the format of yymmdd i want to put it into the format of yy dd mm

Here is how i format a date i call a formatdate function to do it, but in this case i want to swap the format about, from yymmdd to ddmmyy.

DTSDestination("orderDate") = formatDate(DTSSource("Col002"))

Function formatDate(ByVal Value)

' First convert to a date friendly format (yyyy-mm-dd)
Value = Left(Value, 4) + "-" + Mid(Value, 5, 2) + "-" + Mid(Value, 7, 2)

If IsDate(Value) Then ' Is it a valid date?
formatDate = CDate(Value)
Else
GetDate = Null ' If needed replace with some other appropriate value for invalid dates
End If

End Function

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-14 : 07:12:43
Why just not a simple

If CDate(Value) Then
Value = FORMAT(Value, "ddmmyy")
Else
Value = NULL


???


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -