COBOL Intrinsic Date Functions

--> -->
 
 
TypeError
Python 3.10.12: /usr/bin/python
Tue Jul 1 17:49:35 2025

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /home/nhaggin/semperubisububi.net/cgi-bin/breadcrumb.cgi in <module>
     55 
     56 
     57 if __name__ == '__main__':
     58     print('Content-Type: text/plain\n\n')
=>   59     genCrumbs()
genCrumbs = <function genCrumbs>
 /home/nhaggin/semperubisububi.net/cgi-bin/breadcrumb.cgi in genCrumbs()
     48                 continue
     49 
=>   50         crumbs.append('<a href="' + uri + '">' + crumb + '</a>')
     51 
     52     print('<div id="crumbs">')
crumbs = [], crumbs.append = <built-in method append of list object>, uri = 'http://www.semperubisububi.net/', crumb = b'Home'

TypeError: can only concatenate str (not "bytes") to str
      args = ('can only concatenate str (not "bytes") to str',)
      with_traceback = <built-in method with_traceback of TypeError object>

The standard ACCEPT statement for getting the system date was a large part of the Y2K problem, since it only allowed for two-digit years. The 1989 revision of the COBOL standard introduced the following functions for doing date manipuation, all of which use four-digit years. Of course, these will not prevent a Y10K problem, but by then one may hope that COBOL will have been superseded.

Since CURRENT-DATE expects an alphanumeric item, whereas the other functions expect plain numeric items, you should define the data item used to get the current date as follows:

01  DATE-TODAY.
    05  DATE-TODAY-NUM PIC 9(8).
			

OR

01  DATE-TODAY PIC X(8).
01  DATE-TODAY-NUM REDEFINES DATE-TODAY PIC 9(8).
			

Then use DATE-TODAY with CURRENT-DATE and DATE-TODAY-NUM with everything else.

NB. In the following explanations, "numeric" always means PIC 9 DISPLAY.

CURRENT-DATE

Syntax

MOVE FUNCTION CURRENT-DATE TO data-item.

Action

Returns the current date in YYYYMMDD format. data-item must either be PIC X(8) or a group item.

INTEGER-OF-DATE

Syntax

COMPUTE dest = FUNCTION INTEGER-OF-DATE (source).

Action

Converts source into an integer representing the number of days between December 31, 1600 and source and stores it in dest. source must be a numeric data item containing a date formatted YYYYMMDD. dest must be a numeric data item of at least 6 digits.

DATE-OF-INTEGER

Syntax

COMPUTE dest = FUNCTION DATE-OF-INTEGER (source).

Action

Converts source into a date formatted YYYYMMDD and stores it in dest. source must be a numeric data item. dest must be a numeric data item of 8 digits.

INTEGER-OF-DAY

Syntax

COMPUTE dest = FUNCTION INTEGER-OF-DAY (source).

Action

Converts source into an integer representing the number of days between December 31, 1600 and source and stores it in dest. source must be a numeric data item containing a date formatted YYYYDDD; this is sometimes referred to as a date in Julian format. dest must be a numeric data item of at least 6 digits.

DAY-OF-INTEGER

Syntax

COMPUTE dest = FUNCTION DAY-OF-INTEGER (source).

Action

Converts source into a date formatted YYYYDDD and stores it in dest. source must be a numeric data item containing a positive integer. dest must be a numeric data item of 7 digits.