To check for the Date Formats
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
"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
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