%YEARS Built-In Functions in rpgle

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

It is used in the format %YEARS(Number of Years).


Example -%YEARS Built-In Functions in rpgle




Columns . . . :    6  80         Browse                           AMITCC/QRPGLESRC
SEU==>                                                                    BIN_YEAR
FMT D  DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
*************** Beginning of data *****************************************
0001.00 DDATE0            S               D   INZ(D'2011-01-12')
0002.00 DDATE1            S               D
0003.00 DTIMESTP0         S               Z
0004.00 DTIMESTP1         S               Z
0005.00 C                   EVAL      DATE1=DATE0 + %YEARS(2)
0006.00 C     DATE0         DSPLY
0007.00 C     DATE1         DSPLY
0008.00 C                   TIME                    TIMESTP0
0009.00 C                   EVAL      TIMESTP1=TIMESTP0 - %YEARS(2)
0010.00 C     TIMESTP0      DSPLY
0011.00 C     TIMESTP1      DSPLY
0012.00 C                   SETON                                        LR
****************** End of data *******************************************


Output

2011-01-12                                            
2013-01-12                                            
2013-02-01-01.28.10.071000                            
2011-02-01-01.28.10.071000   











User Comments:



Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy