Date processing continues to be a pain in the neck for many RPG programmers. RPG III still does not support true date fields, while RPG IV and DDS do. Consequently, those who have not moved their entire set of applications to RPG IV have decided to not use date fields in their database files.
In V5R2, IBM added a date format code to the %CHAR built-in function that allows you to specify the resulting format of the date value that is generated.
In V5R3, IBM has added the capability to convert a numeric value into a date value and specify the format that the value is stored in. The %DATE built-in function now converts a numeric value into a date value. The second parameter of %DATE allows you to specify the format of the non-date value that you are converting. This allows you to compare or assign a non-date value to a true date variable.
Prior to V5R2, you had to use the MOVE operation code to convert the non-date value to a true date field and then use that field to compare.
While things are getting easier, it would still be beneficial if IBM would add true date data-type support to the RPG III language. But don't hold your breath.
The following are examples of the techniques explained above:
D DueDate2 S D Datfmt(*ISO)
D dueDate S 8S 0
/IF DEFINED(*V5R3M0)
C if %Date(dueDate:*ISO) > Today
/ELSEIF DEFINED(*V5R2M0)
C if %int(%Char(dueDate)) >
C %Int(%char(NewDate:*ISO0))
/ELSE
C *ISO0 MOVE dueDate dueDate2
C if dueDate2 > Today
/ENDIF
Bob Cozzi is a programmer/consultant, writer/author, and software developer of the RPG xTools, a popular add-on subprocedure library for RPG IV. His book The Modern RPG Language has been the most widely used RPG programming book for nearly two decades. Along with others, he speaks at and runs the highly popular RPG World, a conference for RPG programmers.



Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online