converting varchar to Date and validation

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
e1994264
Premium Member
Premium Member
Posts: 28
Joined: Mon Jul 18, 2011 5:12 pm

converting varchar to Date and validation

Post by e1994264 »

Hi,
My source is flatfile . I have date data in varchar type iin my source.
My goal is covert the varchar to date format and vheck for valid date format (%yyyy-%mm-%dd)

In Transformation In Constrains I used following
IsValid( DSLink2.Date,TrimLeadingTrailing( StringToDate(DSLink2.Date,"%yyyy-%mm-%dd")))

And in column Derivation i trie dthe following:
If len(TrimLeadingTrailing( DSLink2.Date))=10 Then StringToDate(DSLink2.Date,"%yyyy-%mm-%dd") Else ' '


But it is not working . Please can any body tell me the solutions
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

IsValid() tests the string. Don't apply StringToDate() first. What you really want is something like

Code: Select all

If IsValid(InLink.TheString, "date") Then StringToDate(InLink.TheString) Else SetNull()
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply