Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
The cool %DATE() and %TIMESTAMP() built-in functions are wonderful tools in RPG IV. They allow use to do all kinds of things, such as:
But how do you use %DATE to return the job's date "job date"?
In RPG III you would use the UDATE or the *DATE "figurative" constants.
Well, RPGIV bests that, slightly: You have two methods.
D jobDate S D Inz(*JOB) D myJobDate S D /free myJobDate = %date(UDATE); /end-free
On line 1, the date variable JOBDATE is initialized using one of the 3 available initialization constants, *JOB. This constant tells the compiler to initialize this date variable to the job date.
On line 4, the %DATE built-in function is being used. Now normally this built-in function returns the system date. However, it also converts non-date values to true date data-types. Therefore, by passing in the UDATE figurative constant, we can convert UDATE (which is the Job Date) into a true date variable. We could also use *DATE which works exactly the same.