iPgmr.com                      Date Processing API                      $$DATEcgi

$$DATE is an RPG program that processes date related requests. It will verify dates, convert dates between formats, and compute the number of days between dates or the span of time in years, months and days. In addition it identifies the day of the week and if a date corresponds to an observed holiday.

  • Submit any one date, from or to, to validate and convert the date.
  • Submit a from date and a to date to calculate the days elapsed.
  • Submit a from date and a number of days elapsed to compute the to date.
  • Submit a to date and a negative number of days to compute the from date.
Scroll down to see a full list of the API parameters. $$DATE updates all parameters with every call so any combination of dates can be sent. For example, from date may be sent as a julian date and and to date can be sent as a calendar date with a 2 digit or 4 digit year. The returned API will have from and to dates in all formats as well as date spans computed. This provides a great deal of flexibility for use within application programs.

From Date   MMDDYY
To Date   MMDDYY
Days Elapsed  


$$DATE was originally written in 1998 to address the challenges of Y2K. It was developed with the intention to be adaptable to new date calculations. That was done by making the API for $$DATE a single 512 byte data structure. Doing so allowed new input and output data elements to be inserted into the data structure that would be processed only if submitted. Existing calls to $$DATE would remain unaffected as they make no reference to the new data elements.

Adding $$DATE to a program is simple. A /COPY compiler directive copies the D$PARM data structure definition into the calling program. The CLEAR opcode initializizes D$PARM sub-fields to nulls. Load input variables and call $$DATE. That's it. The returned data structure will have all sub-field values updated and available for use in the calling program.

$$DATE API Data Structure D$PARM

Field Name From To Description
D$FERR 1 1 From date error indicator **
D$FCMD 2 9 From date CCYYMMDD
D$FMDC 10 17 From date MMDDCCYY
D$FCJD 18 24 From date CCYYDDD (julian)
D$FYMD 25 30 From date YYMMDD ##
D$FMDY 31 36 From date MMDDYY
D$FYJD 37 41 From date YYDDD (julian)
D$FFDH 42 42 From federal holiday (Y/N)
D$FPRH 43 43 From payroll holiday (Y/N)
D$FCLH 44 44 From calendar holiday (Y/N)
D$FHCD 45 47 From holiday code ++
D$TERR 61 61 To date error indicator **
D$TCMD 62 69 To date CCYYMMDD
D$TMDC 70 77 To date MMDDCCYY
D$TCJD 78 84 To date CCYYDDD (julian)
D$TYMD 85 90 To date YYMMDD ##
D$TMDY 91 96 To date MMDDYY
D$TYJD 97 101 To date YYDDD (julian)
D$TFDH 102 102 To federal holiday (Y/N)
D$TPRH 103 103 To payroll holiday (Y/N)
D$TCLH 104 104 To calendar holiday (Y/N)
D$THCD 105 107 To holiday code ++
D$DERR 121 121 Days error indicator (blank=valid, X=not numeric, 1=unable to compute)
D$DYSE 122 126 Days elapsed (5,0; includes from but not to date)
D$DYSB 127 131 Days between (5,0; excludes from and to date)
D$DYSI 132 136 Days inclusive (5,0; includes from and to date)
D$SERR 151 151 Span error indicator (blank=valid, X=non-numeric, 1=unable to compute)
D$YMDE 152 158 Years, months, days elapsed (YYYMMDD, includes from but not to date)
D$YMDB 159 165 Years, months, days between (YYYMMDD, excludes from and to date)
D$YMDI 166 172 Years, months, days inclusive (YYYMMDD, includes from and to date)
D$FMOL 191 199 From month name, left adjusted
D$FMOR 200 208 From month name, right adjusted
D$FMCD 209 211 From month code (JAN, FEB, MAR, ... DEC)
D$TMOL 231 239 To month name, left adjusted
D$TMOR 240 248 To month name, right adjusted
D$TMCD 249 251 To month code (JAN, FEB, MAR, ... DEC)
D$FDWL 271 279 From day of week, left adjusted
D$FDWR 280 288 From day of week, right adjusted
D$FDCD 289 291 From day of week code (MON, TUE, WED, THU, FRI, SAT, SUN)
D$TDWL 311 319 To day of week, left adjusted
D$TDWR 320 328 To day of week, right adjusted
D$TDCD 329 331 To day of week code (MON, TUE, WED, THU, FRI, SAT, SUN)
D$FDMC 361 368 From date DDMMCCYY
D$FDMY 369 374 From date DDMMYY
D$TDMC 381 388 To date DDMMCCYY
D$TDMY 389 394 To date DDMMYY
  395 512 Available for future use


**   blank=valid date   0=zero date   9=all nines   X=non-numeric  
  1=invalid year   2=invalid month   3=invalid day  

##   Two digit years (YY) are converted to four digit years (CCYY)
  based on program constant @WDWYR (window year).
     CC=19 where YY >= @WDWYR
     CC=20 where YY < @WDWYR
  NOTE: @WDWYR=50; to be changed to 60 on 01/01/2020.

++   NYD=New Years Day   MLK=Martin Luthor King Day   PRD=President's Day  
  MEM=Memorial Day   IND=Independence Day   LAB=Labor Day  
  COL=Columbus Day   VET=Veteran's Day   THK=Thanksgiving Day
  CHR=Christmas Day