%DAYS Built-In Function in rpgle

%DAYS converts a number into a duration(No. of days). We can use this duration to add or subtract to a date or timestamp value.

Hence by using %DAYS, we can get any previous dates or future date.


Example – %days 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 DToday            S               D                                        
0002.00 DPrevDay          S               D                                        
0003.00 DTodaysTime       S               Z                                        
0004.00 DPrevTime         S               Z                                        
0005.00 C                                                                          
0006.00 C                   Eval      Today  = %date()                             
0007.00 C     Today         DSPLY                                                  
0008.00 C                                                                          
0009.00 C* Move back by 1 days                                                     
0010.00 C                                                                          
0011.00 C                   Eval      PrevDay=Today - %Days(1)                     
0012.00 C     PrevDay       DSPLY                                                  
0013.00 C                                                                          
0014.00 C                                                                          
0015.00 C                   TIME                    TodaysTime                     
0016.00 C     TodaysTime    DSPLY                                                  
0017.00 C* Move back by 1 days                                                     
0018.00 C                   EVAL      PrevTime=TodaysTime - %Days(1)               
0019.00 C     PrevTime      DSPLY                                                  
0020.00 C                   Seton                                        LR        
        ****************** End of data ********************************************

Output

DSPLY  2017-11-14                      
DSPLY  2017-11-13                      
DSPLY  2017-11-14-17.05.21.216000      
DSPLY  2017-11-13-17.05.21.216000   










User Comments:



Subscribe

  Email:



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