


The DATE directive creates a map between SQL date fields and COBOL numeric fields. Because there's no COBOL syntax that identifies a field as a date, you should add this directive to differentiate dates from other numbers. This way, when a Windows application requests date information, AcuODBC will be able to respond properly.
Syntax
$XFD
DATE=date-format-string
This directive implies the NUMERIC
directive.
or
*(( XFD DATE=date-format-string ))
The date-format-string is a description of the desired date format, composed of characters from the following list:
Any other characters cause the date format string to be invalid, and result in a "corrupt XFD" error or a compile-time warning.Y year (2 or 4-digit) M month (01 - 12) D day of month (01 - 31) J Julian day (00000000 - 99999999) E day of year (001 - 366) H hour (00 - 23) N minute S second T hundredth or thousandth of a second
Each character in a date format string can be considered a place holder that represents the type of information stored at that location. The characters also determine how many digits will be used for each type of data.
For example, although you would typically represent the month with two digits, if you specify MMM as part of your date format, the resulting date will use three digits for the month, left-zero-filling the value. If the month is given as M, the resulting date will use a single digit, and will truncate on the left.
If you don't specify a date-format-string, the default is YYMMDD if the field has six digits, or YYYYMMDD if the field has eight digits.
Julian dates
Because the definition of Julian day varies, the DATE directive offers a great deal of flexibility for representing Julian dates. Many source books define the Julian day as the day of the year, with January 1st being 001, January 2nd being 002, and so forth. If you want to use this definition for Julian day, simply use EEE (day of year) in your date formats.
Other reference books define the Julian day as the number of days since some specific "base date" in the past. This definition is represented in the DATE directive with the letter J (for example, a six-digit date field would be preceded with the directive "$XFD DATE=JJJJJJ"). The default "base date" for this form of Julian date is January 1, 1900.
You may define your own base date for Julian date calculations by setting the "Julian Base Date" field in the AcuODBC Advanced Options screen.
Using group items
You may place the DATE directive in front of a group item, so long as you also use the USE GROUP directive.
Example 1
$xfd date
The column date_hired will have
eight digits and will be type DATE in the
database, with a format of YYYYMMDD.
03 date-hired pic 9(8).
03 pay-scale pic x(3).
Example 2
*(( XFD DATE, USE GROUP ))
This also will produce a column
named date_hired with eight digits and type
DATE in the database, format YYYYMMDD.
03 date-hired.
05 yyyy pic 9(4).
05 mm pic 9(2).
05 dd pic 9(2).
Example 3
*(( XFD DATE=YYYYEEE))
This will produce a column named
date_sold with seven digits and type DATE in
the database. The date will contain the day of the year (for example,
February
1st would be 032), followed by the four-digit year, such as 1999).
03 date-sold pic 9(7).
03 sales-rep pic x(30).