RPG – Job Date & System Date

Job date in RPG

The job date is available as a six digit date in the reserved word UDATE.  This can easily be converted to a standard date field:

myCurrentDate= %date(udate:*dmy); // convert UDATE to date field

 

Similarly, the reserved word *DATE contains the job date but in an eight-digit format.

myCurrentDate= %date(*date); // convert *DATE to date field

 

Note: The job date always contains the date when the job started. When the duration of a job spans multiple days, the values in UDATE and *DATE will not automatically change.  For batch jobs, UDATE/*DATE contains the date when the job was submitted.

The job date can also be placed into a variable defined in the D specifications using the INZ keyword.

D JobDate         s               d   inz(*job)

System date in RPG

The system date can also be placed into a variable defined in the D specifications using the INZ keyword.

D SystemDate1      s               d   inz(*sys)

The system date can also be referenced in the C specifications…

D SystemDate2      s               d   

/free
     SystemDate2 = %DATE();  // No parameters are present so the current system date returned in *ISO format.
/end-free

Note: The system date can change duration the duration of a job or even whilst a program is running which could lead to unexpected results.