Check whether input is of an expected date format

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
sumesh.abraham
Participant
Posts: 153
Joined: Thu May 11, 2006 1:52 am
Location: Bangalore

Check whether input is of an expected date format

Post by sumesh.abraham »

Hi,

I want to check whether input date field is of expected format for date fields in different files. If I pass the expected length and date format to a routine, will the below example work

Code: Select all

If Len(Arg1)=8 And Not(IsNull(Iconv(Arg2,'DMDY[2,2,4]'))) Then
 Ans=1
End
Else
Ans=0
I've to write the record to an error table if date validation fails.

Does IsValid function check this?

Is there any other solution?

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

Post by ray.wurlod »

You may need to adapt the IsValid() function (for server) because it is a little more forgiving of date format.

Note also that Iconv() does not return NULL unless the date is actually NULL. You would do better to check the result of the Status() function after applying the Iconv() function.

Did you mean Arg1 to be the argument of Iconv()?
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