To check for the Date Formats

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
cmueller
Participant
Posts: 46
Joined: Wed Oct 23, 2002 7:10 am

Post by cmueller »

Try: If Not(Arg1 Matches "2N":"/":"2N":"/":"4N") Then...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

"D4-DMY" is an argument for am Iconv() or Oconv() function. Specifically, it is not a pattern that can be used by the Matches operator.
To check whether a date is valid, check the value returned by the Status() function once an Iconv() has been applied.
To check whether it's a valid date pattern, as cmueller suggests, is not sufficient, as it would allow "78/82/0001".

Example Routine to test valid date:

FUNCTION IsValidDate(Arg1)
* Returns 1 if Arg1 is valid date, 0 otherwise.
* Iconv doesn't have to worry about actual delimiter.
* However, we do require a four digit year.
Test = Iconv(Arg1, "D4DMY")
* Status() returns 0 for valid date
Ans = Not(Status())
RETURN(Ans)


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply