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.
Validate the Date
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
Iconv(InputDate,"D-YMD[4,2,2]") status will tell that.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
As JG says use the Iconv in a routine
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.
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
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.
Regards,
Nick.
Nick.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Rather than I'd prefer
Code: Select all
Len(InputDate) = 8
Code: Select all
InputDate Matches "8N"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
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)
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
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.