RPGLE last day of month example

RPGLE Sample Code to get last day of the Current Month or any given date


D Start_date      S               D                                      
D End_date        S               D                                      
D My_date         S               D   inz(d'2011-03-15')                 
D My_date2        S              8s 0 inz(20110415)                      
  
                                                                     
 /free                                                                   
    Start_date = %date(%subst(%char(%date()):1:8) + '01':*ISO);          
    End_date  = Start_date + %months(1) - %days(1);                      
    dsply End_date;                                                      
                                                                         
    Start_date = %date(%subst(%char(My_date):1:8) + '01':*ISO);          
    End_date  = Start_date + %months(1) - %days(1);                      
    dsply End_date;                                                      
                                                                         
    Start_date = %date(%subst(%char(%date(My_date2)):1:8) + '01':*ISO); 
    End_date  = Start_date + %months(1) - %days(1);                      
    dsply End_date;                                                      
 /end-free        

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.