%DATE
The %DATE function returns the current date or verifies and converts a value to a date in YYYYMMDD format.
When specifying a value you can also specify the format of that value and the date separator. The function checks that the value is a valid date in the format specified and returns the date in YYYYMMDD format. If the value is not a valid date, an error occurs.
Format
%DATE([value[, format[, separator]]])
Parameters
value
A value that represents a date. Defaults to *CURRENT which returns the current date. Any other value must be a valid date in the format specified.
With *DMY, *MDY and *YMD formats, date separators are optional but if specified must match the format entered in parameter 3.
The day component may be 1 or 2 digits if date separators are used or format *DMY is used but must be 2 digits if date separators are not used and format *MDY or *YMD is specifed.
The month component may be 1 or 2 digits if date separators are used but must be 2 digits if date separators are not used.
The year component may be 2 or 4 digits or may be omitted. If omitted, the current year is assumed.
With *TXT format, the input date is a character string up to 32 characters long which contains a 3 character month abbreviation (Jan, Feb, etc.), a 1 or 2 digit day component and optionally a 4 digit year component, space delimited but in no specific positions. If the year component is not found, the current year is assumed.
format
Determines the format of the input value. Defaults to *YMD if omitted. Ignored when *CURRENT is specified as the value.
*DMY | The input value is a date in DMY format |
*MDY | The input value is a date in MDY format |
*YMD | The input value is a date in YMD format |
*TXT | The input value is a date in text format |
separator
Determines the date separator character. Defaults to * if omitted. Ignored when *CURRENT is specified as the value.
* | The character specified by system value QDATSEP is used |
other | Valid characters are / - . , |
Return value
Returns a numeric value that represents a date in yyyymmdd format.