Easytrieve does not isolate dates into a single mystical type the way SQL DATE columns do. In practice, dates are numeric zoned fields, packed counters, or alphabetic strings whose meaning comes from how you define overlays, masks, and processing logic. A six-byte DATE-OF-HIRE field might store 031585 as March 15, 1985 in MMDDYY layout. CURR-DATE in classic sample programs lives in static storage S, populated by %GETDATE at job start, then decomposed into CURR-MM, CURR-DD, and CURR-YY for service-year calculations. SYSDATE appears on report titles as eight characters often containing slash separators. Beginners who treat dates as plain integers without format rules compare 031585 to 120124 incorrectly or compute age with two-digit year century bugs. This page teaches date field patterns, system date retrieval, overlay components, and service calculation idioms from Broadcom training examples.
The most common batch pattern defines a contiguous date as type N with zero decimal positions—whole digits only. FILE layouts from COBOL programs often use PIC 9(6) for MMDDYY or PIC 9(8) for YYYYMMDD without decimal semantics. Easytrieve reads those bytes as zoned decimal digits. No special DATE keyword is required on DEFINE when numeric storage already matches the file.
12345678910FILE PERSNL FB(150 1800) 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 CURR-DATE S 6 N CURR-MM CURR-DATE 2 N CURR-DD CURR-DATE +2 2 N CURR-YY CURR-DATE +4 2 N
Overlay syntax reuses parent field location with offset. HIRE-MM takes bytes one and two of DATE-OF-HIRE; HIRE-DD skips two bytes with +2; HIRE-YY takes last two bytes. This avoids redundant position math in IF statements. Month and day comparisons use two-byte N fields directly—IF CURR-MM LT HIRE-MM triggers service-year adjustment logic in payroll examples. Overlays must not exceed parent length and should match file endianness and digit order documented in copybook.
SYSDATE supplies the current system date for use in TITLE lines, DISPLAY diagnostics, and assignments. Training macro examples assign SYSDATE into an eight-byte alphabetic work field GETDATE-DATE, then manipulate substrings to strip slash separators for six-digit numeric user dates. Report titles commonly show SYSDATE at column sixty for run-date stamping. Treat SYSDATE format as installation-dependent—verify display in test JCL before production title layout hard-codes column positions.
1234567JOB INPUT PERSNL %GETDATE CURR-DATE PERFORM SERVICE-CALC PRINT UPD-RPT REPORT UPD-RPT LINESIZE 80 TITLE 01 'PAYROLL UPDATE' COL 60 SYSDATE
The GETDATE macro facility loads current date into a parameter field you name at invocation. Sample definition creates internal work fields, assigns SYSDATE, strips slashes, and moves six-digit result into the caller field. Invocation looks like %GETDATE CURR-DATE early in JOB before service calculations. Macros centralize date retrieval so fifty programs do not duplicate substring logic. LIST NOMACROS suppresses macro expansion listing when desired.
Broadcom payroll sample computes SERVICE as year difference adjusted for month and day not yet reached in anniversary sense. Start with CURR-YY minus HIRE-YY. If current month less than hire month, subtract one year. If months equal but current day less than hire day, subtract one year. This idiomatic PROC avoids date routines for simple seniority rules but fails on century boundaries if YY is two-digit—see date formats page for CCYY mitigation.
12345678910111213SERVICE-CALC. PROC SERVICE = CURR-YY - HIRE-YY IF CURR-MM LT HIRE-MM SERVICE = SERVICE - 1 END-IF IF CURR-MM NE HIRE-MM GOTO QUIT-SERV-CALC END-IF IF CURR-DD LT HIRE-DD SERVICE = SERVICE - 1 END-IF QUIT-SERV-CALC END-PROC
| Location | Meaning | Typical date use |
|---|---|---|
| FILE position | Date from input record | HIRE-DATE, INVOICE-DATE |
| W | Working storage | Temporary converted dates |
| S | Static storage | CURR-DATE set once per run |
CURR-DATE in samples uses S so the run date fetched by %GETDATE remains stable while processing thousands of detail records. Re-fetching date inside every record loop is wasteful and could theoretically cross midnight on long jobs—static run date is standard audit practice.
External dates with separators may use type A with length eight or ten. MASK Z9/99/99 on numeric fields produces slash editing on output without changing stored digits. Choose storage to match upstream systems—do not store slashes inside N fields meant to be pure digits unless file layout requires them.
For validation, conversion, and day arithmetic beyond simple overlays, installations may provide %DATEVAL, %DATECONV, and %DATECALC routines. DATEVAL checks validity against format literals like MMDDCCYY. DATECONV transforms between formats with THRESHOLD century control. DATECALC adds or subtracts days. These complement—not replace—basic N field overlays for hire date reporting.
A date in Easytrieve is like writing your birthday as six numbers in a row: month, day, year—031585 for March 15, 1985. The program can cut that string into three pieces without scissors by overlay rules. Today's date comes from the computer clock through GETDATE and gets written on the report like a stamp saying when you ran the job.
1. Legacy Easytrieve hire dates in sample programs typically use type:
2. SYSDATE provides:
3. %GETDATE macro loads date into:
4. Static storage S on CURR-DATE means:
5. Breaking DATE-OF-HIRE into HIRE-MM uses: