Search code examples
servertimestampibm-midrangerpg

RPG - IBM i TimeStamp format


I'm working on an IDE (CA Plex) which doesn't support TimeStamp format but ironically it works with an IBM i server (AS400) which works with TimeStamps with the following format: yyyy-MM-dd-hh.mm.ss.mmmsss

I'm using a RPG function which calculates the difference between two TimeStamps as the code shows:

  *  Difference between two TimeStamps in ms
  /FREE
   &(3:) = %DIFF (&(1:): &(2:): *MSECONDS);
  /END-FREE

&(1:), &(2:) and &(3:) are the parameters sent by the IDE which are incompatible with the function. The TimeStamp format sent is the same I explained before, but RPG compiler doesn't recognize them as TimeStamp. How can I format those parameters? Somethink like this is what I need:

tstampone = %timestamp(&(1:));
tstamptwo = %timestamp(&(2:));

*  Difference between two TimeStamps in ms
/FREE
   &(3:) = %DIFF (tstampone: tstamptwo: *MSECONDS);
/END-FREE

Compiler throws warnings: RNF0580 and RNF0581


Solution

  • Found the answer:

      /FREE
        &(3:) = %DIFF (%TIMESTAMP(&(1:)): %TIMESTAMP(&(2:)): *MS);
      /END-FREE