Blog Archive

RPGLE first day of month example

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


D Start_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);                 
    dsply Start_date;                                                           
                                                                                
    Start_date = %date(%subst(%char(My_date):1:8) + '01':*ISO);                 
    dsply Start_date;                                                           
                                                                                
    Start_date = %date(%subst(%char(%date(My_date2)):1:8) + '01':*ISO);        
    dsply Start_date;                                                           
 /end-free