Groups | Blog | Home
all groups > sql server dts > january 2005 >

sql server dts : Date Transformation from YYYYMMDD


bradm98
1/7/2005 10:05:05 AM
I'm very new to DTS, but here goes:
I've got a source file with dates stored as YYYYMMDD, and I'd like to move
the data into a datetime field. I've figured out the basic transformation
steps, but I'm running into a problem with source dates = '00000000' (e.g.
obsolete_date = '00000000' for products that are not obsolete).

From a 'Best Practices' standpoint, what is the best way to handle this?
I've considered a few options, but I'm not experienced enough to anticipate
the cost/benefit of each down the road:

1. Change destination field def to match source (char(8)) - I'll be using a
fair amount of date functions, though, so this adds extra work for all
queries, etc.
2. Script a transformation that changes '00000000' to NULL
2. Script a transformation that changes '00000000' to some other value
(e.g. Dec 31, 9999)

Amy
1/7/2005 12:42:04 PM
I am new to DTS also, so this may not be the best way-but I think it
may be the easiest, I would use an ActiveX Script Transformation
Properties and use an IF/THEN statement. It would look something like
this:

'**********************************************************************
' Visual Basic Transformation Script
'************************************************************************

' Copy each source column to the destination column
Function Main()


IF DTSSource("sourcefieldname") > "0" THEN
DTSDestination("fieldname") = DTSSource("sourcefieldname")
END IF

Main = DTSTransformStat_OK
End Function

If you haven't used this function in DTS Package yet, let me know I can
walk you through it in more detail. Hope this helps.

Good Luck!

Amy
AddThis Social Bookmark Button