Easytrieve Date Formats

A date format is an agreement about what each digit position means—not a separate Easytrieve type code. Six digits might be March 15, 1985 in MMDDYY or May 31, 1985 in YYMMDD if you misread the copybook. Eight digits might be 19850315 in CCYYMMDD or a corrupted sort key if someone swapped month and day. Julian YYDDD packs year and day-of-year into five digits common in tape management and legacy control files. Easytrieve handles formats through field length, overlay components, edit masks like Z9/99/99, and optional routines DATECONV, DATEVAL, and DATECALC with format literal parameters. This page compares format families, documents THRESHOLD century rules, and gives beginners a checklist for matching file layout to processing logic without silent century bugs.

Progress0 of 0 lessons

Common External Format Families

Mainframe date format patterns
Format nameTypical digitsExample meaningEasytrieve approach
MMDDYY6 N031585 = Mar 15, 1985Overlays MM DD YY on N 6
YYMMDD6 N850315 = Mar 15, 1985Overlays YY MM DD
MMDDCCYY8 N03151985Four-byte year overlay CCYY
CCYYMMDD8 N19850315 ISO-styleSort-friendly century first
YYDDD Julian5 N85074 = day 74 of 1985DATECONV with YYDDD literal
Display with slashes8–10 A or masked N03/15/85SYSDATE or MASK Z9/99/99

MMDDYY Six-Digit US Layout

Classic Easytrieve training files use six-byte N DATE-OF-HIRE with month day year overlays. Sorting MMDDYY strings lexically as numbers does not sort chronologically within a year—031585 before 122584 correctly by month but cross-year sorts need CCYY or internal day count. Reports printing hire dates often apply MASK Z9/99/99 so 031585 displays as 03/15/85 with slashes inserted at print time only.

text
1
2
3
4
5
DATE-OF-HIRE 136 6 N HIRE-MM DATE-OF-HIRE 2 N HIRE-DD DATE-OF-HIRE +2 2 N HIRE-YY DATE-OF-HIRE +4 2 N MASK Z9/99/99

Century Formats MMDDCCYY and CCYYMMDD

Eight-digit formats eliminate two-digit year ambiguity when century is stored explicitly. CCYYMMDD supports straight numeric sort as chronological sequence—19850315 before 19991231. MMDDCCYY keeps US month-first readability with four-digit year trailing. Overlay design changes: CCYY may occupy bytes five through eight or one through four depending on format. Transcription errors from six-digit legacy files often pad century with 19 or 20 constants in assignment logic—document assumptions in program header comments.

Julian YYDDD

Julian format stores two-digit year plus three-digit day-of-year 001 through 366. Tape management and operations files use Julian for compact sorting by day within era. Easytrieve DATECONV documentation states the only valid Julian format literal is YYDDD—not MM DD combinations. Converting Julian input to Gregorian output requires DATECONV with correct format pair; manual division is error-prone near leap years.

Format Literals in DATECONV and DATEVAL

Routines accept format parameters built from letter pairs: MM month, DD day, YY year, CC century. Pairs may appear in any order for non-Julian dates—MMDDCCYY, YYMMDD, DDMMYY per documentation examples. CC requires YY in the same format specification. DATEVAL validates field content against format before conversion. Invalid dates like month 13 set DATEVAL-FLAG to NO instead of silently corrupting downstream fields.

text
1
2
3
4
%DATEVAL INPUT-DATE MMDDCCYY IF DATEVAL-FLAG EQ 'YES' %DATECONV INPUT-DATE MMDDCCYY OUTPUT-DATE CCYYMMDD END-IF

THRESHOLD Century Control

When source dates use two-digit years without CC, THRESHOLD on DATECONV and DATECALC assigns centuries. Example from documentation: processing 1949–1952 with THRESHOLD 50 maps 49 and 50 to 2049 and 2050 while 51 and 52 remain 1951 and 1952. Wrong THRESHOLD shifts entire cohort eligibility dates in pension reports. Prefer eight-digit storage for new interfaces; reserve THRESHOLD for legacy feeds you cannot change immediately.

Edit Masks for Printed Dates

Getting Started lists standard masks including Z9/99/99 for dates and 99/99/99 for social security style grouping. Each nine in mask maps to one digit from numeric field. Z suppresses leading zeros in some positions per mask rules. Commas in masks print only when value magnitude warrants—date masks focus on slash placement. MASK on DEFINE applies to LINE TITLE DISPLAY without altering stored N digits.

SYSDATE Display Format

SYSDATE often appears as eight characters including slash separators in macro examples— 11/24/83 style—while user numeric fields strip slashes to 112483 six-digit form. Know which format each variable carries before comparing to FILE dates. Conversion macros encapsulate strip logic so application code receives consistent six-digit N.

Choosing a Format for New Development

  1. Prefer CCYYMMDD eight-digit N when file design is under your control.
  2. Match existing COBOL copybook exactly when reading legacy files—do not reinterpret.
  3. Document format in FILE comment and program maintenance header.
  4. Use DATEVAL before DATECONV on unchecked external feeds.
  5. Apply SEQUENCE on CCYYMMDD keys for chronological reports without extra SORT.

Format Comparison Pitfalls

  • Sorting six-digit MMDDYY as numeric for multi-year ranges.
  • Assuming YY 00 is 1900 vs 2000 without THRESHOLD policy.
  • Mixing SYSDATE slash form with pure digit FILE fields in IF.
  • Using MMDDYY DATECONV literal on YYMMDD data—silent wrong output.
  • Ignoring leap day 366 in Julian validation.

Explain It Like I'm Five

Date format is the order you say birthday parts: month-day-year versus year-month-day. If everyone agrees March 15, 1985 is 031585, the computer reads it correctly. If one file uses 850315 and another 031585 without labels, the computer thinks different days. Julian is a special code counting days in the year like day seventy-four instead of naming March. Always check the label on the box before opening the numbers inside.

Exercises

  1. Define overlays for CCYYMMDD with separate CCYY MM DD subfields.
  2. Explain why CCYYMMDD sorts chronologically as plain numeric.
  3. Write DATEVAL call for MMDDCCYY input with flag check.
  4. Describe THRESHOLD impact on year 50 with threshold 50.
  5. Add MASK Z9/99/99 to six-digit hire date for report print.

Quiz

Test Your Knowledge

1. Format literal MMDDYY means:

  • Two-digit month, day, year in that order
  • Julian day only
  • Eight-byte alphabetic
  • Packed decimal cents

2. Only valid Julian format in DATECONV documentation is:

  • YYDDD
  • MMDDYY
  • CCYYMMDD
  • DDMMCCYY

3. THRESHOLD on DATECONV controls:

  • Two-digit year century assignment
  • File buffer size
  • REPORT LINESIZE
  • Packed sign nybble

4. Edit mask Z9/99/99 is used for:

  • Date display with slashes
  • Telephone numbers
  • Packed tax amounts
  • Binary flags

5. Before DATECONV you should use DATEVAL when:

  • You need to verify date content is valid for the format
  • Compiling only
  • Defining FILE DCB
  • Setting STEPLIB
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve DATECONV DATEVAL format literals MMDDYY YYDDD THRESHOLDSources: Broadcom Easytrieve 11.6 DATECONV DATEVAL DATECALC, Getting Started edit masksApplies to: Easytrieve external date format selection and conversion