DATEVAL
The DATEVAL function converts a nondate to a date field, for unambiguous use with date fields.
If the DATEPROC compiler option is in effect, the returned value is a date field containing the value of argument-1 unchanged. For information about using the resulting date field:
- In arithmetic, see Arithmetic with date fields
- In conditional expressions, see Comparison of date fields
If the NODATEPROC compiler option is in effect, the DATEVAL function has no effect, and returns the value of argument-1 unchanged.
The function type depends on the type of argument-1:
Argument type | Function type |
---|---|
Alphanumeric | Alphanumeric |
Integer | Integer |
- argument-1
- Must be one of the following:
- A class alphanumeric item with the same number of characters as the date format specified by argument-2.
- An integer. This can be used to specify values outside the range specified by argument-2, including negative values.
The value of argument-1 represents a date of the form specified by argument-2.
- argument-2
- Must be an alphanumeric literal specifying a date pattern, as
defined in DATE FORMAT clause.
The date pattern consists of YY or YYYY (representing a windowed
year or expanded year, respectively), optionally preceded or followed
by one or more Xs (representing other parts of a date, such as month
and day), as shown below. Note that the values are case insensitive;
the letters X and Y in argument-2 can be any
mix of uppercase and lowercase.
Date-pattern string Specifies that argument-1 contains YY A windowed (two-digit) year YYYY An expanded (four-digit) year X A single character; for example, a digit representing a semester or quarter (1–4) XX Two characters; for example, digits representing a month (01–12) XXX Three characters; for example, digits representing a day of the year (001–366) XXXX Four characters; for example, two digits representing a month (01–12) and two digits representing a day of the month (01–31)