Convert Gregorian Date to Julian Date and vice-versa

We often need to convert date from one format to another. This can be done using COBOL intrinsic functions.











The below code is present in the above screenshot.

01 WS-GREGORIAN-DATE           PIC 9(08).    
01 WS-JULIAN-DATE              PIC 9(07).    

COMPUTE WS-JULIAN-DATE    = FUNCTION DAY-OF-INTEGER      
                            (FUNCTION INTEGER-OF-DATE    
                            (WS-GREGORIAN-DATE))        
                                                                                                              
COMPUTE WS-GREGORIAN-DATE = FUNCTION DATE-OF-INTEGER 
                            (FUNCTION INTEGER-OF-DAY 
                            (WS-JULIAN-DATE))

No comments: