Easytrieve Date Data Type

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.

Progress0 of 0 lessons

Dates as Numeric Fields

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.

text
1
2
3
4
5
6
7
8
9
10
FILE 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 Components

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 System Variable

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.

text
1
2
3
4
5
6
7
JOB INPUT PERSNL %GETDATE CURR-DATE PERFORM SERVICE-CALC PRINT UPD-RPT REPORT UPD-RPT LINESIZE 80 TITLE 01 'PAYROLL UPDATE' COL 60 SYSDATE

%GETDATE Macro

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.

Service Year Calculation Pattern

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.

text
1
2
3
4
5
6
7
8
9
10
11
12
13
SERVICE-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

Static S vs Working W for Run Date

Storage locations for date fields
LocationMeaningTypical date use
FILE positionDate from input recordHIRE-DATE, INVOICE-DATE
WWorking storageTemporary converted dates
SStatic storageCURR-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.

Character Dates and MASK

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.

Date Routines When Logic Grows

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.

Common Date Mistakes

  • Comparing six-digit dates without agreeing MMDDYY vs YYMMDD order.
  • Two-digit year rollover treating 01 as before 99 incorrectly.
  • Overlay offset +2 errors shifting day and year subfields.
  • Using P 2 decimals on date fields—dates are whole digit N.
  • Expecting SYSDATE numeric six-digit without conversion from display form.

Explain It Like I'm Five

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.

Exercises

  1. Define six-byte N hire date with MM DD YY overlays.
  2. Write JOB line invoking %GETDATE for CURR-DATE in static storage.
  3. Explain SERVICE-CALC year adjustment when hire month is December and current is January.
  4. Add TITLE with SYSDATE at column 60.
  5. List three storage options for keeping run date in a batch program.

Quiz

Test Your Knowledge

1. Legacy Easytrieve hire dates in sample programs typically use type:

  • N zoned numeric overlays
  • A 50 character text
  • P packed currency
  • I 8 integer only

2. SYSDATE provides:

  • Current system date in display form for titles and logic
  • File EOF status
  • Compiler version
  • Random number seed

3. %GETDATE macro loads date into:

  • A user-specified receiving field parameter
  • JCL only
  • SYSPRINT exclusively
  • REPORT TITLE only

4. Static storage S on CURR-DATE means:

  • Value persists across program logic per static storage rules
  • Field is read-only from file
  • Type is alphabetic
  • Cannot use overlays

5. Breaking DATE-OF-HIRE into HIRE-MM uses:

  • Overlay subfields on parent field
  • Floating point
  • REPORT LINE only
  • SQL UPDATE
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve sample programs DATE-OF-HIRE CURR-DATE %GETDATE SYSDATE patternsSources: CA-Easytrieve Plus 6.4 Application Guide, Broadcom Easytrieve 11.6 Getting Started, DATECONV DATEVAL DATECALCApplies to: Easytrieve date field definition and run-date retrieval