Hi, Frank. Based on your reported results, it appears that you are running the compiles calling the integer-of-formatted-date function with the INTDATE(LILIAN) compiler option specified. For an explanation of how the INTDATE(ANSI|LILIAN) option affects the date and time intrinsic function calculations, please refer to the section titled "Using date callable services" in the Enterprise COBOL Programming Guide, Here's a partial summary for you.
Both the COBOL date intrinsic functions and the Language Environment date callable services are based
on the Gregorian calendar. However, the starting dates can differ depending on the setting of the INTDATE
compiler option.
When INTDATE(LILIAN) is in effect, COBOL uses October 15, 1582 as day 1. Language Environment
always uses October 15, 1582 as day 1. If you use INTDATE(LILIAN), you get equivalent results from
COBOL intrinsic functions and Language Environment date callable services.
When the default setting of INTDATE(ANSI) is in effect, COBOL uses January 1, 1601 as day 1.
To answer your second question about the use of the formatted-current-date function, the Enterprise COBOL Language Reference states the following:
argument-1
Must be a national, a UTF-8, or an alphanumeric literal.
The content of argument-1 must be a combined date and time format. For details, see "Date and time
formats" on page 468.
Please let me know if I have not addressed your questions fully.
------------------------------
Greg Doolittle
------------------------------
Original Message:
Sent: Mon June 14, 2021 01:37 PM
From: Frank Swarbrick
Subject: Questions about new date/time intrinsic functions
Given the following:
01 dateint pic s9(7) comp-3.[...] compute dateint = integer-of-formatted-date ('YYYYMMDD' '20210614') display dateint display formatted-date('YYYY-MM-DD' dateint) compute dateint = integer-of-date(20210614) display dateint display formatted-date('YYYY-MM-DD' dateint)
The integer-of-formatted-date function seems not to give the correct result. Or am I doing something wrong?
+00153567 2003-03-28
The integer-of-date function is correct.
+00160220 2021-06-14
Also a question about formatted-current-date. These two work fine:
display formatted-current-date('YYYYMMDDThhmmss.ss+hhmm') display formatted-current-date('YYYY-MM-DDThh:mm:ss.sss')
These two don't compile:
display formatted-current-date('YYYYMMDD') display formatted-current-date('YYYY-MM-DD')
52 IGYPA3382-S The specified date, time, or combined date and time format string argument-1 "'YYYYMMDD'" is not a valid input for "ALPHANUMERIC FUNCTION FORMATTED-CURRENT-DATE". The statement was discarded. 53 IGYPA3382-S The specified date, time, or combined date and time format string argument-1 "'YYYY-MM-DD'" is not a valid input for "ALPHANUMERIC FUNCTION FORMATTED-CURRENT-DATE". The statement was discarded.
The messages seem to indicate that a "date only" format string is allowed, but its not accepting the ones I tried here.
------------------------------
Frank Swarbrick
------------------------------