TEST-DATE-YYYYMMDD

The TEST-DATE-YYYYMMDD function tests whether a date in standard date form (YYYYMMDD) is a valid date in the Gregorian calendar. Argument-1 of the INTEGER-OF-DATE function must be in standard date form.

The function type is integer.

Format

Read syntax diagramSkip visual syntax diagram FUNCTION TEST-DATE-YYYYMMDD ( argument-1 )
argument-1
Must be an integer.

Returned values

  • If the value of argument-1 is less than 16010000 or greater than 99999999, the returned value is 1, which means the year is not within the range of 1601 to 9999.
  • If the value of FUNCTION MOD (argument-1 10000) is less than 100 or greater than 1299, the returned value is 2, which means the month is not within the range of 1 to 12.
  • If the value of FUNCTION MOD (argument-1 100) is less than 1 or greater than the number of days in the month determined by FUNCTION INTEGER (FUNCTION MOD (argument-1 10000)/100) of the year determined by FUNCTION INTEGER (argument-1/10000), the returned value is 3, which means the day is not valid for the given year and month.
  • Otherwise, the returned value is 0 (zero) , which means the date is valid.

Examples

FUNCTION TEST-DATE-YYYYMMDD (19950215) returns 0 because the date is valid.

FUNCTION TEST-DATE-YYYYMMDD (12950215) returns 1 because the year is invalid and the value of argument-1 is less than 16010000.

FUNCTION TEST-DATE-YYYYMMDD (912950215) returns 1 because the year is invalid and the value of argument-1 is greater than 99999999.

FUNCTION TEST-DATE-YYYYMMDD (19921415) returns 2 because the month is not within the range of 1 to 12 and the value of FUNCTION MOD (argument-1 10000) is less than 100 or greater than 1299.

FUNCTION TEST-DATE-YYYYMMDD (19950240) returns 3 because the day is invalid for the given year and given month.