ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Different value of the system time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Different value of the system time

    Hello. If you initialize a variable of type timestamp like this:
    Code:
    dcl-s ts1 timestamp inz(*sys);
    then the microseconds value will not be filled completely. The last 3 characters will be zeros: 2022-07-14-12.28.49.272000

    However, if you find out the system time like this:
    Code:
    ts1 = %timestamp(*sys);
    then the microseconds are filled in completely: 2022-07-14-12.28.50.302264.

    Explain why so?

  • #2
    The answer is "Because". Because that is the way that RPG is documented to work. The microsecond support from the system that SQL supports is (relatively) new and RPG did not initially adapt to utilize it. As of the Spring 2020 updates you can now get microseconds in RPG but apparently initialization was not included in that enhancement, Details are here: https://www.ibm.com/support/pages/rp...onds-timestamp

    So you need to add initialization logic an either set the timestamp via SQL or via %Timestamp.

    Comment

    Working...
    X