The TEST-FORMATTED-DATETIME Function

ENTMF 

Description

The TEST-FORMATTED-DATETIME function tests the validity of a specified date, time or combined-datetime according to the format specified. The type of this function is integer.

General Format

FUNCTION TEST-FORMATTED-DATETIME (argument-1, argument-2)

Arguments

  1. Argument-1 must a literal of type alphanumeric, UTF-8 or national, that contains a date, time or combined data time format. See Date and Time formats for details.
  2. Argument-2 must be of the same type as argument-1.

Returned Values

  1. The return value is the character offset to the first error in argument-2, or 0 if argument-2 is valid according to the format in argument-1. Errors can be incorrect characters, incorrect length, invalid value ranges or invalid dates.

Example

Using the following arguments generates a return value of 5, as the fifth character of argument-2 ("4") contains an incorrect value for the first digit of the month representation.

FUNCTION TEST-FORMATTED-DATETIME(“YYYYMMDD", "20124523")