Date handling drives payroll cycles, billing cutoffs, eligibility windows, and audit headers. Easytrieve combines system date constants such as SYSDATE and SYSDATE-LONG, calendar macros including %DATECALC and %DATEVAL, overlay fields for MONTH DAY and YEAR on fixed records, and—on Plus installations—additional Application Reference date builtins. Relational IF compares require aligned internal formats: CCYYMMDD character, packed numeric, or Julian layouts must match between EFF-DATE and CUTOFF-DATE or silent wrong selection results. This index catalogs date capabilities by name, contrasts macro versus function-call syntax, explains header and cutoff patterns, and links to per-function pages as the tutorial series expands. Beginners from SQL DATEADD must unlearn assuming one universal function name exists on every mainframe LPAR.
Library DEFINE assigns type N P A or D per field. Legacy files store MMDDYY in six digits; modern extracts use CCYYMMDD in eight character positions. Julian five-digit layouts appear in aging reports. The date function or macro you choose must output the same representation as the fields it feeds. Converting once into WS-COMPARE-DATE before IF logic reduces repeated conversion bugs across multiple conditions in one JOB.
| Operation | Mechanism | Notes |
|---|---|---|
| Current system date | SYSDATE | Headers, audit stamps, run date |
| Extended date/time | SYSDATE-LONG | Timestamp-style precision per release |
| Add/subtract days | %DATECALC macro | Calendar-aware arithmetic |
| Validate date | %DATEVAL macro | Reject invalid calendar dates |
| Extract month/day/year | Overlay on date field | Fixed layout records |
| Compare effective range | IF with GE LE on aligned fields | Inclusive/exclusive bounds |
| Age in years | Macro or procedural subtract | Leap year rules in macro |
| Display format | MASK or conversion category | See formatting index |
Assign processing date once at job start: RPT-DATE = SYSDATE into field matching report MASK. TITLE lines embed RPT-DATE for operator recognition on spool. SYSDATE-LONG may include time or extended calendar precision—consult constants-by-release tutorial and your Application Reference for exact length and type. Do not call per record when header date is invariant for entire batch run—hoist assignment before JOB INPUT loop.
12345678910JOB ACTIVITY PAYROLL-RPT RUN-DATE = SYSDATE JOB INPUT PAYROLL IF PAY-DATE LE RUN-DATE PRINT CURRENT-PAY-RPT END-IF REPORT PAYROLL-SUMMARY TITLE 'REGISTER AS OF ' RUN-DATE
Macro invocation differs from function parentheses syntax—follow SAMPJCL or maclib documentation shipped with your release. %DATECALC adds or subtracts days accounting for month length and leap years when implemented per macro source. %DATEVAL returns validity indicator for date strings before you MOVE into master file fields. Macros require maclib concatenation in compile JCL—missing macro library causes compile failures teams confuse with syntax errors.
Broadcom example: DATE-OF-BIRTH six N with MONTH DAY YEAR two bytes each. IF MONTH EQ 12 selects December births without date function. Overlay cost is zero at runtime—preferred when file layout is stable. Changing upstream file layout breaks overlays—coordinate with data dictionary owners before layout migrations.
12345678BIRTH-DATE 50 6 N BIRTH-MM 50 2 N BIRTH-DD 52 2 N BIRTH-YY 54 2 N IF BIRTH-MM EQ 01 PRINT JANUARY-BIRTHDAY-RPT END-IF
Period processing: IF TRAN-DATE GE PERIOD-START AND TRAN-DATE LE PERIOD-END. Exclusive end: use LT with next-day constant or LE with documented adjustment. Same-day inclusion: LE on cutoff date. Month-end jobs align PERIOD-END to last calendar day via DATECALC rather than manual thirty-one assumption.
Raw numeric add on MMDDYY—adding 100 to January 31 does not yield February correctly. Use DATECALC or documented calendar function for day arithmetic. Age calculation from birth date to SYSDATE must account for birthday not yet reached this year—procedural IF or macro parameter handles borrow rules beginners get wrong in one line of subtraction.
Batch jobs often need date only; audit trails may need time from SYSDATE-LONG or TIME constant documented under system category. Mixing date-only compare with timestamp field truncates or fails—split date and time overlays when file stores combined value.
Dates are calendar numbers stored in special boxes. SYSDATE asks the computer what today is. DATECALC is a calendar robot that counts days forward without skipping month lengths. Overlay is reading just the month digits from a longer birthday number. Before you say is this date before that date, both must use the same kind of calendar box—otherwise you compare apples to shoe sizes.
1. SYSDATE typically provides:
2. Before IF EFF-DATE GT CUTOFF you must:
3. %DATECALC macro is used for:
4. MONTH DAY YEAR overlay on DATE-OF-BIRTH avoids:
5. SYSDATE-LONG compared to SYSDATE often adds: