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.
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 datesEnd IfEnd 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 LarssonHelsingborg, Sweden |
|
|
|
|
|