%HOURS Built-In Functions in rpgle

%HOURS converts a number into a duration(No. of hours). We can use this duration to add or subtract to a time or timestamp value. Hence by using %HOURS, we can get any previous time or future time.

Format of this function is %HOURS (Number)


Example - %HOURS built-in function in RPGLE




 Columns . . . :    6  80                                              AMIT/QRPGSRC
 SEU==>                                                                     TESTRPG
 FMT *   *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8
        *************** Beginning of data *****************************************
0001.00 DTIME0            S               T   INZ(T'10.12.15')                     
0002.00 DTIME1            S               T                                        
0003.00 DTIMESTP0         S               Z                                        
0004.00 DTIMESTP1         S               Z                                        
0005.00 C                   EVAL      TIME1=TIME0 + %HOURS(2)                      
0006.00 C     TIME0         DSPLY                                                  
0007.00 C     TIME1         DSPLY                                                  
0008.00 C                   TIME                    TIMESTP0                       
0009.00 C                   EVAL      TIMESTP1=TIMESTP0 - %HOURS(2)                
0010.00 C     TIMESTP0      DSPLY                                                  
0011.00 C     TIMESTP1      DSPLY                                                  
0012.00 C                   SETON                                        LR        
        ****************** End of data ********************************************


Output

DSPLY  10.12.15                           
DSPLY  12.12.15                           
DSPLY  2017-11-19-15.30.32.215000         
DSPLY  2017-11-19-13.30.32.215000   










User Comments:



Subscribe

  Email:



Copyright © www.go4as400.com, 2013-2017. Copyright notice