Key Takeaways: Date and Time Processing

  1. Y2K taught permanent lessons: Always use 4-digit years, always validate dates, always test boundary conditions. Date windowing is still in production — know its expiration date.

  2. Never subtract YYYYMMDD dates directly. Use FUNCTION INTEGER-OF-DATE to convert to integer day numbers, perform arithmetic on the integers, and use FUNCTION DATE-OF-INTEGER to convert back. This handles all calendar complexities automatically.

  3. FUNCTION CURRENT-DATE returns 21 characters: 8 date (YYYYMMDD) + 8 time (HHMMSScc) + 5 GMT offset (sHHMM). Parse it into a structured group item for easy access.

  4. Date validation is mandatory before any date arithmetic. INTEGER-OF-DATE abends on invalid dates. Validate: numeric check, year range, month range, day range with month/day/leap-year logic.

  5. The leap year rule has three parts: Divisible by 4 (yes), EXCEPT divisible by 100 (no), EXCEPT divisible by 400 (yes). 2000 was a leap year; 1900 was not.

  6. Aging calculations use date subtraction to assign items to buckets (Current, 30, 60, 90, 120+ days). Use the same calculation everywhere to avoid inconsistencies.

  7. Business day calculations combine day-of-week determination (INTEGER-OF-DATE with MOD) and holiday table lookups (SEARCH ALL on sorted dates).

  8. Timezone handling uses the GMT offset from CURRENT-DATE, with careful handling of day-boundary crossings near midnight.

  9. Language Environment date services (CEECBLDY, CEEDATM) provide formatted output and flexible input parsing on z/OS, complementing the intrinsic functions.

  10. One date module, used everywhere. Duplicate date logic guarantees inconsistency. Build a centralized date utility and call it from every program that processes dates.