HELP: Convert date/timestamp data type
TYPE: OBJECT
SYNTAX: DATE(FROM(FORMAT.{STR(PATTERN='str',CHRSET=num/NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL)/BCD(TYPE=UNPACKED/PACKED/ZONED,PATTERN='str')/DEC(ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,SIZE=num,PATTERN='str')/INT(SIZE=num,ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,EPOCH=UNIX/LILIAN/J2000,UNIT=SS/MS/US/NS/DS)},PIVOT=num,NULLVAL='str',ERRACT=FAIL/SKIP/NULLIFY,FROM='str',TO='str'),TO(FORMAT.{STR(PATTERN='str',CHRSET=num/NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL,PAD=num,WIDTH=num)/BCD(TYPE=UNPACKED/PACKED/ZONED,PATTERN='str')/DEC(ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,SIZE=num,PATTERN='str')/INT(SIZE=num,ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,EPOCH=UNIX/LILIAN/J2000,UNIT=SS/MS/US/NS/DS)},NULLVAL='str'))
This object converts a date or timestamp field from its external byte encoding (ASCII/EBCDIC string, BCD zoned/packed decimal, or binary integer) into a neutral ISO-8601 formatted UTF-8 date string for storage in the FL5 archive.
The FORMAT sub-object selects the external byte encoding: - FORMAT.STR: ASCII or EBCDIC digit string (PIC X, char[]) -- default - FORMAT.BCD: binary coded decimal, zoned (PIC 9 DISPLAY) or packed (COMP-3) - FORMAT.DEC: binary unsigned integer (COMP, COMP-5)
Each FORMAT sub-object accepts an optional PATTERN parameter that specifies the external byte layout using tokens such as YYYY (4-digit year), YY (2-digit year with PIVOT-based century assignment), MM (month), DD (day), DDD (Julian day-of-year), HH (24h hour), HH12 (12h hour), MI (minute), SS (second), sss (milliseconds), ssssss (microseconds), and literal separator characters (- / : T Z space). If PATTERN is omitted inside the sub-object, the format is auto-detected from the input length and value ranges.
The internal neutral format is ALWAYS ISO-8601 UTF-8 -- it is determined automatically from the PATTERN tokens by the component and is NOT configurable from outside. There is no OUTFMT parameter. All DATE converters use the same neutral format, ensuring full interoperability: - Date-only PATTERN (YYYYMMDD, YYYYDDD, ...) -> "YYYY-MM-DD" - With time tokens (YYYYMMDDHHMISS) -> "YYYY-MM-DDTHH:MI:SS" - With milliseconds (sss) -> "YYYY-MM-DDTHH:MI:SS.sss" - With microseconds (ssssss) -> "YYYY-MM-DDTHH:MI:SS.ssssss" - Partial date (YYYYMM) -> "YYYY-MM"
PIVOT controls 2-digit year interpretation: years <= PIVOT map to 2000+, years > PIVOT map to 1900+. Default: 49.
NULLVAL specifies a byte pattern that is treated as a null value and results in an empty output string.
ERRACT controls parse-error behaviour: FAIL (default) returns FLMRTC_FMT, SKIP silently omits the row, NULLIFY emits an empty string.
The same rowspec can be used for both TABLEIN (reading) and TABLEOUT (writing): TYPE.DATE(FORMAT.BCD(TYPE=PACKED PATTERN='YYYYMMDD')) Read: 5 packed-BCD bytes -> "2026-04-28" Write: "2026-04-28" -> 5 packed-BCD bytes
FROM and TO are relevant ONLY when the row specification drives a SEARCH in an archive (MATCH.DATASET). They limit the result to the records whose value in this column lies inside a time window, and they are ignored for plain data conversion. Both are optional; without them no window is checked at all.
The window is an addition to the record comparison and changes nothing before it. A wildcard in the match record still selects first, and the column index (signature) keeps working -- searching '1974*' still uses the index to pick the segments that can contain 1974, and the window then reduces what is left:
record '1974*' -> all dates of the year 1974 FROM='1974-07-01' TO='1974-12-31' -> only the second half of it
Because a window can only be evaluated per record, it decides the search method when none was requested: SUBSET stays AUTO by default and then becomes RECORD as soon as a window is present. An explicitly requested SUBSET=SEGMENT is not overruled. The window is then simply not applied yet -- the caller receives the matching segments with the data still compressed and encrypted, and the window remains part of the filter, so running the very same filter with RECORD later (for example where the data is actually unpacked) applies it there.
Both bounds are written in ISO-8601, independent of the PATTERN declared for the column. That keeps one notation for every encoding: the same window works on FORMAT.STR, FORMAT.BCD, FORMAT.DEC and FORMAT.INT, because the value is always compared in the neutral ISO form. No time zone is involved -- the bound is expressed in exactly the same terms as the stored value.
A bound may be shorter than the column's neutral form; it is then filled to the matching end of the period, so a whole month or year is easy to select:
column YYYY-MM-DDTHH:MI:SS, FROM='1974-07' -> 1974-07-01T00:00:00 column YYYY-MM-DDTHH:MI:SS, TO='1974-07' -> 1974-07-31T23:59:59
Both bounds include their own value. Write '>' in front of FROM or '<' in front of TO to exclude it. On a coarse bound the exclusion covers the whole period it names, which is what one expects from "after July":
FROM='1974-07-01' from that day on, the day included FROM='>1974-07-01' from the day after FROM='>1974-07' from August on TO='<1975-01-01' up to but not including new year TO='<1974-07' up to the end of June
A marker in the wrong direction (a '<' on FROM), an unknown marker and a malformed bound are all refused rather than reinterpreted.
The window works whatever shape the column's neutral form has, including a column whose date format is auto-detected: the bound is expanded to the longest ISO shape once, and the comparison then uses the length of the value at hand.