Validate the Date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Validate the Date

Post 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.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

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>
nick.bond
Charter Member
Charter Member
Posts: 230
Joined: Thu Jan 15, 2004 12:00 pm
Location: London

Post 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.
Regards,

Nick.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Rather than

Code: Select all

Len(InputDate) = 8
I'd prefer

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.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post 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)
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>
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post 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.
Post Reply