Date, time, and timestamp fields using FMTOPT(*MAP) or FMTOPT(*NOCHK)

You must specify FMTOPT(*MAP) or FMTOPT(*NOCHK) on the CPYF command in any of the follow cases: Corresponding date, time, and timestamp fields in the from-file and to-file must have the same format attribute and separator for the record formats to be identical. For the CPYFRMQRYF command, the same is true except that the open query file record format is used (rather than a from-file format).

When using FMTOPT(*NOCHK), record data is copied directly from left to right into the to-file without any regard to field types.

When using FMTOPT(*CVTSRC), data portions of records are directly copied from left to right into the to-file without any regard to the field types.

When using FMTOPT(*DROP), fields in the from-file but not in the to-file are dropped. If any like-named fields in the from-file and to-file are date, time, or timestamp fields, the corresponding field must be the same type, have the same format attribute and separator, and have the same relative position in the record format as the like-named field, otherwise FMTOPT(*MAP) might also be required.

FMTOPT(*MAP) allows copying between like date, time, and timestamp field types regardless of the format or separator. Also, copies from and to date, time, and timestamp fields are allowed from and to zoned-decimal or character field types, provided the lengths, formats, and values can be converted. FMTOPT(*MAP) is required in this case for conversion to the to-field type (format and separator, if it applies).

Table 1 outlines the conversion possibilities for the date, time, and timestamp.

Table 1. Conversion Table
Data types Forms Allowable field length Direction Data type Formats Allowable field length
Date Any date format 6, 8, or 10 <--> Date Any 6, 8, or 10
Zoned (MMDDYY) 6,0 <--> Date Any 6, 8, or 10
Zoned (DDMMYY) 6,0 <--> Date Any 6, 8, or 10
Zoned (YYMMDD) 6,0 <--> Date Any 6, 8, or 10
Zoned (YYDDD) 5,0 <--> Date Any 6, 8, or 10
Character (MMdDDdYY) 6 min <--> Date Any 6, 8, or 10
Character (DDdMMdYY) 6 min <--> Date Any 6, 8, or 10
Character (YYdMMdDD) 6 min <--> Date Any 6, 8, or 10
Character (YYdDDD) 6 min <--> Date Any 6, 8, or 10
Character (*USA) 6 min  ----> Date Any 6, 8, or 10
Character (*ISO) 6 min  ----> Date Any 6, 8, or 10
Character (*EUR) 6 min  ----> Date Any 6, 8, or 10
Character (*JIS) 6 min  ----> Date Any 6, 8, or 10
Character (YYYYDDD) 6 min  ----> Date Any 6, 8, or 10
Time Any time format 8 <--> Time Any 8
Zoned (HHMMSS) 6,0 <--> Time Any 8
Character (HHtMMtSS) 4 min  ----> Time Any 8
Character (*USA) 4 min  ----> Time Any 8
Character (*ISO) 4 min  ----> Time Any 8
Character (*EUR) 4 min  ----> Time Any 8
Character (*JIS) 4 min  ----> Time Any 8
Character (HHtMMtSS) 8 min <---- Time Any 8
Timestamp SAA® format 26 <--> Timestamp SAA 26
Zoned (YYYYMMDDHHMMSS) 14,0 <--> Timestamp SAA 26
Character SAA format 14 min  ----> Timestamp SAA 26
Character (YYYYMMDDHHMMSS) 14 min <--> Timestamp SAA 26
Note: In the format columns,
d
= date separator value
t
= time separator value
any
= job formats or SAA formats
In the allowable field-length column, min means the specified length is the minimum required for a conversion attempt. Conversion errors might still occur if the length is not long enough for the assumed format that you want. Refer to the DDS concepts for more information about the date, time, and timestamp data types and keywords.
When converting a character field to a date, time, or timestamp field; FMTOPT(*MAP) is specified; and the corresponding from- and to-field names match; an attempt is made to determine what similar date form the character field is in. The following rules applies:
When converting a date, time, or timestamp field to a character field; FMTOPT(*MAP) is specified; and the corresponding from and to-file field names match; the server attempts to convert the date, time, or timestamp field into the form specified by the current job. The following rules applies:
When converting a zoned decimal field to a date, time, or timestamp field, FMTOPT(*MAP) is specified and the corresponding from- and to-field names match, the server assumes the zoned decimal field is in the form specified by the current job. The following rules applies:
When converting a date, time, or timestamp field to a zoned decimal field, FMTOPT(*MAP) is specified and the corresponding from- and to-field names match, the server uses the current job specified form to determine what format the zoned decimal data should be in. The following applies:

Any conversion not successful because of a data value, data format, or data-length error causes an information message to be sent. The to-file field is set with its default value.

Related information
DDS concepts