Search code examples
ibm-midrangerpgle

ILE RPG - How to convert a time value to a numeric value?


Consider the following code:

D#TIME1           S               T                                             
D#numeric1        S              6  0                                           
D#numeric2        S              6  0                                           
D                                                                               
C                   TIME                    #numeric1                           
C                   eval      #TIME1 = %TIME(#numeric1:*HMS)                    
C                                                                               
C*                  This does not work:                                             
C                   eval      #numeric2 = %int(TIME1)                           
C*                  Errormessage: The expression contains a operator, which is not defined
C                                                                               
C                   MOVE      *ON           *INLR            

Can someone please tell me, how I can convert a *HMS time value(like '07:02:22') to a 6 0 numeric value. I need this for comparing two time stamps.


Solution

  • C                   eval      #numeric2 = %dec(TIME1: *hms)  
    

    Should do the trick.