FORMATTED-TIME converts times, it doesn't provide them. The function 
SECONDS-PAST-MIDNIGHT returns the seconds past midnight. It isn't documented 
but it will return fractional seconds, but the best I could get is 3 decimal 
digits (milliseconds).

I tested this last month on z/OS 2.4 with IBM Enterprise COBOL for z/OS 6.2.0.


The OP wants nanoseconds but I would be happy with a HLL interface that can 
return /microseconds/. All the COBOL and Language Environment methods are 
limited to either 2 or 3 digits for fractional seconds. So I use an assembler 
program (TIME MIC,workarea,LINKAGE=SYSTEM).

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of 
Peter Farley
Sent: Sunday, February 18, 2024 10:05 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Nanosecond resolution timestamps for HLL's?

> Have you looked at the FORMATTED-TIME function?

Thanks Paul, I did look at the FORMATTED-TIME function, but the finest 
resolution offered by that function is tenths of milliseconds (four fractional 
decimal digits), not even micro-seconds (which would require six fractional 
decimal digits).  That is not sufficient for accurate application timing values 
on today's hardware.  Two nearly-adjacent calls to that function are quite 
likely to return the same value.

I quote from the latest V6.4 COBOL Language Reference PDF, SC27-8713-03, 
Chapter 29, page 499:

Table 58. The permissible format strings for fractional-seconds time
Fractional-seconds time formats -|- Format literals
Basic local time -|- hhmmss.ssss

Peter

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to