Bryan's RPG IV Journal
Free Format Alternatives to TIME
Q. In fixed format RPG IV, I used the TIME operation code to get the current date and time; but TIME is not supported by free format. You mentioned that the %DATE, %TIME, and %TIMESTAMP functions can replace TIME, but I'm not sure how to use them for this purpose. In my programs, I create a data structure like this:
D DS
D Dtime 14 0
D Wdate 8 0 Overlay(Dtime)
D Wtime 6 0 Overlay(Dtime:*Next)
I've been using TIME to assign a value to Dtime, then I use Wtime and Wdate to assign values to work fields. How can I do this in free format?
A. If you do not specify a value for the %DATE, %TIME, and %TIMESTAMP functions they will return the current date, time, or timestamp. Then, it's a simple matter to convert that value to a number in your data structure. Here's one way to do it:
D DS
D Dtime 14 0
D Wdate 8 0 Overlay(Dtime)
D Wtime 6 0 Overlay(Dtime:*Next)
// V5R3:
Wtime = %Dec(%Time():*ISO);
Wdate = %Dec(%Date():*ISO);
// V5R2:
Wtime = %Dec(%Char(%Time():*ISO0):6:0);
Wdate = %Dec(%Char(%Date():*ISO0):8:0);
Or, if you make a small change to the data structure:
D DS
D Dtime 20 0
D Wdate 8 0 Overlay(Dtime)
D Wtime 6 0 Overlay(Dtime:*Next)
// V5R3:
Dtime = %Dec(%Timestamp());
// V5R2:
Dtime = %Dec(%Char(%Timestamp():*ISO0):20:0);
Log of Journal Entries |
|
Use this scrollable blog map to view other journal entries: |
|
| It is your responsibility to ensure procedures, techniques, and code used from this website are accurate and appropriate for your installation. No warranty or support is implied or expressed. |
![]() |
| Privacy and Email Policy |
| AS/400®, eServer, i5/OS, IBM i, Integrated Language Environment®, iSeries, OS/400®, RPG/400®, System i5, VisualAge®, and WebSphere® are trademarks of IBM Corporation. Note: IBM® System i is the latest member of the family of eServer iSeries. This site might refer to System i as System i5, iSeries, or AS/400. |
|
If you are having trouble navigating the menu at the top of this page, you may use the following scrollable site map instead: |
|
|











International visitors: