Easytrieve Date Functions Index

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.

Progress0 of 0 lessons

Date Representation in Easytrieve

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.

Date Capabilities Index

Date operations and primary mechanisms
OperationMechanismNotes
Current system dateSYSDATEHeaders, audit stamps, run date
Extended date/timeSYSDATE-LONGTimestamp-style precision per release
Add/subtract days%DATECALC macroCalendar-aware arithmetic
Validate date%DATEVAL macroReject invalid calendar dates
Extract month/day/yearOverlay on date fieldFixed layout records
Compare effective rangeIF with GE LE on aligned fieldsInclusive/exclusive bounds
Age in yearsMacro or procedural subtractLeap year rules in macro
Display formatMASK or conversion categorySee formatting index

SYSDATE and SYSDATE-LONG

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.

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

Date Macros DATECALC and DATEVAL

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.

Overlay Extraction

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.

text
1
2
3
4
5
6
7
8
BIRTH-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

Cutoff and Range Patterns

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.

Format Alignment Workflow

  1. Document input file date layout in program header comment.
  2. Define W compare fields matching that layout.
  3. Convert macro or function output into W field before IF.
  4. Test boundary: day before period, first day, last day, day after.
  5. Compare record counts against SQL or sort utility on same file.

Leap Years and Month Boundaries

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.

Date Versus DateTime

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.

Common Date Mistakes

  • Comparing CCYYMMDD to MMDDYY without conversion.
  • Using LT versus LE wrong on cutoff day inclusion.
  • Arithmetic add across month end without DATECALC.
  • SYSDATE per record wasting CPU on invariant value.
  • Two-digit year century assumption on legacy YY fields.
  • Assuming Plus date function names on Report Generator compile.

Explain It Like I'm Five

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.

Exercises

  1. Assign RUN-DATE = SYSDATE once and use in TITLE line.
  2. Write IF window with GE start and LE end on aligned date fields.
  3. Define MONTH overlay on six-byte numeric birth date.
  4. List four test dates for month-end cutoff including boundary day.
  5. Explain why raw add on MMDDYY fails across February.

Quiz

Test Your Knowledge

1. SYSDATE typically provides:

  • Current system date for headers and stamps
  • File record count
  • Sort key
  • JCL class

2. Before IF EFF-DATE GT CUTOFF you must:

  • Align date formats between fields
  • Sort the JCL
  • Close the file
  • Use OR only

3. %DATECALC macro is used for:

  • Adding or subtracting days from dates
  • Opening VSAM
  • String trim
  • Report PAGE

4. MONTH DAY YEAR overlay on DATE-OF-BIRTH avoids:

  • Separate function call for each component
  • All date storage
  • FILE statement
  • JOB keyword

5. SYSDATE-LONG compared to SYSDATE often adds:

  • Extended precision or timestamp detail
  • Alphabetic month name
  • Binary only
  • Nothing—identical always
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve SYSDATE patterns; DATECALC DATEVAL macro usage varies by maclibSources: Broadcom Easytrieve Report Generator 11.6 Getting Started, constants documentationApplies to: Easytrieve date functions macros and compare patterns