dbTalk Databases Forums  

Date Transformation from YYYYMMDD

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Date Transformation from YYYYMMDD in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bradm98
 
Posts: n/a

Default Date Transformation from YYYYMMDD - 01-07-2005 , 12:05 PM






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)

Any other options? What else should I consider when deciding?

Reply With Quote
  #2  
Old   
Amy
 
Posts: n/a

Default Re: Date Transformation from YYYYMMDD - 01-07-2005 , 02:42 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.