Page 1 of 1

converting varchar to Date and validation

Posted: Mon Dec 05, 2011 11:42 am
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

Posted: Mon Dec 05, 2011 3:17 pm
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()