VALIDDATE Function

Purpose

Returns a value to indicate if a string holds a valid date, as indicated by a specified pattern.

Syntax

VALIDDATE(d, p, w)

Parameters

d is the string expression that represents a date. d specifies the input date to be evaluated as a character string representing date/time according to the pattern specified with p.

p is a supported date/time pattern. This parameter is optional. If specified, it specifies the date/time pattern of d. If not specified, VALIDDATE uses the default date/time pattern YYYYMMDDHHMISS999.

w specifies an expression (such as 1976) that can be converted to an integer. A negative value specifies an offset to be subtracted from the value of the year when the code runs. If not specified, w VALIDDATE uses the value specified in the WINDOW option.

Description

The VALIDDATE function returns a '1'B if the string d holds a date/time value that matches the pattern specified by p.

Both the d and p parameters must have computational type and should have character type. If not, they are converted to character.

If the pattern specified by p contains punctuation characters, VALIDDATE checks that the input string contains matching characters. For example, if specifying YYYY-MM-DD, VALIDDATE accepts 2015-03-14 but not 2015.03.14 or 2015/03/14.

See the help topic Date/Time Built-in Functions for more information about supported date/time patterns.

Examples

DCL DUEDATE CHAR(8);
DCL (B1,B2) BIT(1);
DUEDATE = ’20150228’;
B1 = VALIDDATE( DUEDATE, ’YYYYMMDD’ ); /* B1 = ’1’B */
DUEDATE = ’02302015’;
B2 = VALIDDATE( DUEDATE, ’DDMMYYYY’ ); /* B2 = ’0’B */

Restrictions

None.