Using timestamps in RPG: Difference between revisions
Jump to navigation
Jump to search
(New) |
(→Weblinks: Linkfix) |
||
Line 39: | Line 39: | ||
== Weblinks == | == Weblinks == | ||
* [https:// | * [https://www.ibm.com/resources/publications/OutputPubsDetails?PubID=SC41571201 AS/400e DDS Reference], SC41-5712-01 | ||
* [https:// | * [https://www.ibm.com/resources/publications/OutputPubsDetails?PubID=SC09250802 AS/400e ILE RPG for AS/400 Reference], SC09-2508-02 | ||
== Footnotes == | == Footnotes == |
Latest revision as of 13:18, 21 May 2023
Using timestamps in RPG is not as straightforward as using character, or decimal fields.
RPG has an internal way to handle timestamps, which is incompatible with the external representation in externally described fields, such as database- and display files.
Note: Adding the internal date/time handling routines is a compile time option. Use
CVTOPT(*DATETIME)
in aH
line.
Example
- CHANGED
- is a timestamp field in the database (physical file).[1]
- STAMP$
- is a 19 character field in the DSPF, for containing the pretty printed timestamp.
- STAMP
- is the RPGLE defined timestamp (
Z
) field. TheTIME
operator writes to this variable.
- PF:
A CHANGED Z
- DSPF:
A STAMP$ 19A O ...
- RPGLE:
D* For saving/handling timetamp data. DSTAMP S Z D*
For every time we write, or update a record:
C* Current time → Database C TIME STAMP C MOVEL STAMP CHANGED
Database → Pretty print DSPF field
C* Get timestamp, and produce nice version thereof. C MOVEL CHANGED STAMP$ C '.':':' XLATE STAMP$ STAMP$ C '-':' ' XLATE STAMP$:11 STAMP$
See also
Weblinks
- AS/400e DDS Reference, SC41-5712-01
- AS/400e ILE RPG for AS/400 Reference, SC09-2508-02
Footnotes
- ↑ RPG imports that as anything but a timestamp declared in the
D
statements.