The job-date reserved words are valid as the Factor 2 of a MOVE or MOVEL.
They are numeric reserved words, not declared fields: their digits are the job
date ordered by the control-spec DATEDIT keyword (*MDY when DATEDIT is
omitted). UDATE carries a two-digit year (6 digits), *DATE a four-digit one
(8 digits); *YEAR/UYEAR, *MONTH/UMONTH, and *DAY/UDAY carry a single
component each.
Moved into a character result, the word supplies exactly those digits.
Moved into a date result, *DATE and UDATE supply the job date itself - the same DATEDIT ordering that produced the digits is what reads them back, so
the date value is the same under any DATEDIT setting. A two-digit year
resolves in the 1940 - 2039 window. The component words carry only one field and
cannot fill a date result.
(job date 2026-07-28)
C MOVE *DATE c8 (DATEDIT *MDY → '07282026')
C MOVEL UDATE c6 (DATEDIT *MDY → '072826')
C MOVE *DATE c8 (DATEDIT *YMD → '20260728')
C MOVE *YEAR c4 ('2026')
C MOVE *MONTH c2 ('07')
C MOVEL *DATE dIso (date 2026-07-28)
C MOVEL UDATE dIso (date 2026-07-28)
A date, character, or numeric source into a date result
A date, time, or timestamp source of the same type is stored straight
across, with Factor 1 blank. The value is the same instant - only the declared
DATFMT/TIMFMT rendering differs - so the formats need not match:
(d1 is DATFMT(*ISO), d2 is DATFMT(*USA))
C MOVE d1 d2 (d2 renders 07/28/2026)
A character or numeric source converts under a Factor 1 format, which names
the source's layout rather than the result's. MOVE reads the rightmost
characters of the source and MOVEL the leftmost, so a source wider than
the format reaches the same date from either end:
(cr = 'XX07/28/26', cl = '07/28/26XX')
C *ISO MOVE c10 d1 ('2026-07-28' → 2026-07-28)
C *MDY MOVE n6 d1 (numeric 72826 → 2026-07-28)
C *MDY MOVE cr d1 (rightmost 8 → 2026-07-28)
C *MDY MOVEL cl d1 (leftmost 8 → 2026-07-28)
A character source must carry the format's separated form, so *MDY needs
eight characters (07/28/26) rather than six - a shorter field is rejected
outright, and rpgc's conversion refuses it rather than inventing a date. A
numeric source has no separators and converts from its digits, so *MDY
takes six.