Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Get 1st of Month and End of Month in RPGIV
has no ratings.
Published: 19 Sep 2012
Revised: 23 Jan 2013 - 1979 days ago
Last viewed on: 25 Jun 2018 (4444 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Get 1st of Month and End of Month in RPGIV Published by: Bob Cozzi on 19 Sep 2012 view comments(6)

Calculating the 1st of Month in RPG IV

beginMonth = myDate - %Days(%subdt( myDate:*days)-1);  

Calculating the End of Month in RPG IV

endMonth = (myDate + %Months(1)) - %days(%subdt(myDate + %Months(1):*days));

 Test Program that Shows Results

.....H bnddir('COZTOOLS/COZTOOLS')                                              
     H DFTACTGRP(*NO) ACTGRP(*NEW)                                              
     D/include cozTools/qcpysrc,joblog                                          
     D myDate          S               D   Inz(*SYS)                            
     D BOM             S               D                                        
     D EOM             S               D                                        
     C                   MOVE      *ON           *INLR                          
           BOM = myDate - %Days(%subdt( myDate:*days)-1);                       
           EOM = (myDate+%Months(1)) - %days(%subdt(myDate + %Months(1):*days));
           joblog('myDate: %s BOM: %s EOM: %s':                                    



Return to midrangenews.com home page.
Sort Ascend | Descend