STR

Synopsis

HELP:   Date field encoded as ASCII/EBCDIC digit string (PIC X) [default]
TYPE:   OBJECT
SYNTAX: STR(PATTERN='str',CHRSET=num/NONE/SYSTEM/ASCII/UCS1/UTF8/EBCDIC/UCS2BE/UTF16BE/UCS2LE/UTF16LE/UCS4BE/UTF32BE/UCS4LE/UTF32LE/LOCAL)

Description

Reads a date or timestamp field encoded as a character string (PIC X, char[]).

Digit bytes in ASCII (0x30-0x39) and all IBM EBCDIC variants (0xF0-0xF9) are recognised automatically without any CCS parameter. Any separator character that is not a digit is silently consumed. This includes all common date and time separators in both ASCII and EBCDIC character sets as well as unusual or "dirty" separator characters such as backslash (), comma (,), and mixed separator sequences.

AUTO-DETECTION WHEN PATTERN IS OMITTED

When no PATTERN='...' token string is given, FORMAT.STR inspects the raw input bytes and selects the most likely format according to the following rules.

The FIRST separator character determines the default convention:

Dot (.) first: Day-first, European (DD.MM.YYYY) Slash (/) first: Month-first, US (MM/DD/YYYY) -- unless the first two digits exceed 12, in which case Day-first Dash (-) or other: ISO / Year-first (YYYY-MM-DD) -- unless the first group has only 2 digits (then DD-MM-YYYY)

When a 4-digit group appears first (before any separator), the year-first (ISO 8601) family is assumed regardless of the separator type.

A short (2-digit) year in the last position is recognised automatically and the PIVOT rule applies: YY <= 49 maps to 2000+, YY > 49 maps to 1900+.

TIME IS DETECTED automatically when a time-separator character (T, t, space, Z, colon) is found after at least 6 date digits.

DIRTY-INPUT TOLERANCE

The following "dirty" inputs are accepted without error: - Mixed separators: 28-04.2026, 2804/2026, 28,04,2026 - All-same unusual separators: 28,04,2026 - Space as date separator: 28 04 2026 - Extra trailing separators and spaces

For ALL inputs with at least 4 digits, auto-detection NEVER produces an error. If a valid date cannot be formed, ERRACT controls the fallback behaviour (FAIL/SKIP/NULLIFY).

EXAMPLES

"20260428" -> 2026-04-28 (YYYYMMDD compact) "2026-04-28" -> 2026-04-28 (ISO dash) "28.04.2026" -> 2026-04-28 (European dot, DD first) "04/28/2026" -> 2026-04-28 (US slash, MM first) "28/04/2026" -> 2026-04-28 (slash, 28>12 -> DD first) "2804/2026" -> 2026-04-28 (dirty mixed separators) "28-04.2026" -> 2026-04-28 (mixed, first dash -> ISO-like) "28/04/26" -> 2026-04-28 (2-digit year, slash DD first) "2026118" -> 2026-04-28 (YYYYDDD Julian day 118) "26118" -> 2026-04-28 (YYDDD Julian) "260428" -> 2026-04-28 (YYMMDD, value-range check) "2026-04-28T14:30:00" -> 2026-04-28T14:30:00 (ISO datetime) "2026-04-28 14:30:00" -> 2026-04-28T14:30:00 (space as T) "2026.04.28T14:30" -> 2026-04-28T14:30 (dot-ISO with time) "2026" -> 2026 (year only) "2026-04" -> 2026-04 (year-month partial) "20260428143000" -> 2026-04-28T14:30:00 (compact timestamp)

CCS PARAMETER

The optional CCS parameter enables full ICV character-set conversion before digit extraction, covering unusual EBCDIC code pages and multi-byte character sets. When absent, the automatic EBCDIC/ASCII detection is sufficient for all standard IBM mainframe code pages.

Arguments