Page 1 of 1

Validate the Date

Posted: Wed May 16, 2007 9:21 pm
by rafidwh
Hi All,

How to validate a source date.
like if the source date is yyyymmdd,now i need to validate whether it is a eight digit and also in the correct format I mean if the date is like 20012020 and also it is null then I need to reject them.

In a shell I can say that if date is invalid and null then reject.

Please through some ideas,

Thanks in advance,
Rami.

Posted: Wed May 16, 2007 9:34 pm
by JoshGeorge
Iconv(InputDate,"D-YMD[4,2,2]") status will tell that.

Posted: Wed May 16, 2007 10:01 pm
by nick.bond
As JG says use the Iconv in a routine

Code: Select all

* Convert the date to internal
vInternalDate = Iconv(InputDate,"DYMD[4,2,2]") 
* Check the status of Iconv
vStatus = Status()

*Check the length of the input = 8. Problems with dates like 200701
If Len(InputDate) = 8 Then vStatus = vStatus Else vStatus = 1
Ans = vStatus
Status codes are

0 The conversion was successful.

1 The string was invalid. An empty string was returned, unless string was a null value when null was returned.

2 The conversion was invalid.

3 Successful conversion but the input data may be invalid, for example, a nonexistent date, such as 31 September.

Posted: Wed May 16, 2007 11:31 pm
by ray.wurlod
Rather than

Code: Select all

Len(InputDate) = 8
I'd prefer

Code: Select all

InputDate Matches "8N"

Posted: Wed May 16, 2007 11:35 pm
by JoshGeorge
Add this in your transformer constraint - Oconv(Oconv(Iconv(Input.date,"DYMD"),"DYMD"),"MCN")= Input.date - This filters out invalid dates (will check for the length 8 also)

Posted: Thu May 17, 2007 12:48 am
by rafik2k

Code: Select all

Job Type: Parallel 

Are you using server job or parallel job?

In case of parallel job you can't use iconv/oconv function.