How to convert Julian to Gregorian dates

Technote (FAQ)


Question

How to convert a Julian date to a Gregorian date in COBOL?

Answer

Here is an example using Intrinsic FUNCTIONs:

 
DATA DIVISION.                                      
WORKING-STORAGE SECTION.                            
01  JJ  PICTURE 9(7)  VALUE 1999032.                
01  GG  PICTURE 9(8).                              
01  DD  PICTURE 9(8).                              
PROCEDURE DIVISION.                                
 DISPLAY " JULIAN INPUT      " QUOTE JJ QUOTE.      
 COMPUTE DD = FUNCTION INTEGER-OF-DAY(JJ).          
 COMPUTE GG = FUNCTION DATE-OF-INTEGER(DD).      
 DISPLAY " GREGORIAN OUTPUT  " QUOTE GG QUOTE.  
                                               
 Results are - - -                      
 JULIAN INPUT      "1999032"                    
 GREGORIAN OUTPUT  "19990201"  

Note: The DD data area is used to store the number of days since the start of the relevant calendar.

In the example above, the Julian date is converted to a number of days by INTEGER-OF-DAY and the number of days is converted to a Gregorian date by DATE-OF-INTEGER.

The calendar used depends on the INTDATE compiler option setting.


Cross reference information
Segment Product Component Platform Version Edition
Software Development COBOL for VSE/ESA Runtime

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Enterprise COBOL for z/OS
Runtime

Software version:

3.4, 4.1, 4.2

Operating system(s):

z/OS

Reference #:

1003813

Modified date:

2002-02-13

Translate my page

Machine Translation

Content navigation