Micro Focus and ACUCOBOL support DATE directives in the XFD. Using the DATE directive, a COBOL field can be mapped to the desired time and date format. This directive applies to a numeric XFD field. The syntax is as follows:
*>>XDD DATE=date-format-string
If the date-format-string is not supplied, 6-digit fields are interpreted as YYMMDD and 8-digit fields are interpreted as YYYYMMDD.
If a different date format is required, the date-format-string can be used to specify the format using these characters:
All other characters are invalid and will cause an error.
Example 1
This example creates "date-hired" column with type DATE based on an 8-digit field with the default format of YYYYMMDD:
*>>XDD date
03 date-hired pic 9(8).
03 pay-scale pic x(3).
Example 2
This example shows a different way to produce a column named "date-hired" with type DATE based on an 8-digit field with a format of YYYYMMDD:
*>>XDD DATE
*>>XDD USE GROUP
03 date-hired.
05 yyyy pic 9(4).
05 mm pic 9(2).
05 dd pic 9(2).
Example 3
This example produces a column named "date-sold" with type DATE. The date is based on a 7-digit field that contains the day of the year (e.g., February 1st is 032), followed by the four-digit year (e.g., 2018).
*>>XDD DATE=EEEYYYY
03 date-sold pic 9(7).
03 sales-rep pic x(30).