Help in constraint for Date 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
vskr72
Premium Member
Premium Member
Posts: 128
Joined: Wed Apr 28, 2004 9:36 pm

Help in constraint for Date validation

Post by vskr72 »

I have the following recrods from a file. (I am showing only 1 colunmn for simplicity). I haev to perform a Date validation and if it fails, then I need to write it to a flat/reject file. The data is coming from a fixed with file. The constraint I have is like this:

Code: Select all

NOT(Isvalid ("date", Datecol,"%yyyy%mm%dd"))
Expectation is that this should be true only for a invalid date format. All the valid date formats and NULL should be skipped. SO only real invalid dates shodul go the reject file. I used TRIM and that was also not workign either. Any thoughts?
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Re: Help in constraint for Date validation

Post by vamsi.4a6 »

1)Define a stage variable
If Isvalid ("date", Datecol,"%yyyy%mm%dd") then 1 else 0-sv

2)Use constraint sv=0
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

vamsi.4a6 wrote:1)Define a stage variable
If Isvalid ("date", Datecol,"%yyyy%mm%dd") then 1 else 0-sv

2)Use constraint sv=0
A couple of learning points:

There really isn't any difference between the two posted approaches (other than one checks for true and the other false), so unless we know the why of the "not working" comment I doubt it will help. Also, there's no need for the if-then-else wrapper for the derivation, especially one that sets the output to 1 or 0. As shown in the original post, they will always derive "true" or "false" automagically, which also just so happens to be 1 (technically non-zero) and 0 under the covers.

So, having said that... vskr72, can you post actual examples of your incoming records? Can you also confirm the data type you are using for these 'date' fields? You also said you only showed us one column, can we assume you need to check multiple date fields and reject the record if any of them are invalid? If so, I'd be curious what your full constraint looks like.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Handle nulls first.
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