Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time in Miliseconds

Status
Not open for further replies.

Matzi

Programmer
Dec 15, 2011
2
DE
Hello,

I'm searching for a function or program routine, which
returns time in miliseconds or microseconds.
The programs are running on a B2000-Host (Fujitsu; not IBM or CICS; no UNIX).
The Function CURRENT-DATE resolves to hundredths of a second, and unfortunately no finer.

Thank you very much

Matzi
 
With CURRENT-DATE you get only hundreds of seconds.
But if you are working with SQL-database, you can retrieve it from it.

I'm working with DB2, so I'm using in COBOL embedded SQL - something like this:
Code:
...
       WORKING-STORAGE SECTION.
      * copy SQLCA
           EXEC SQL
             INCLUDE SQLCA
           END-EXEC.

       01 ZW-FELDER.
      *   DATE, TIME and TIMESTAMP datatypes
          05 ZW-TIMESTAMP             FORMAT OF TIMESTAMP.  

...
       PROCEDURE DIVISION.
...
       AKT-DATUM-ZEIT-ERMITTELN.
      *    Selecting 26-character DB2-TimeStamp
           EXEC SQL
             SET :ZW-TIMESTAMP = CURRENT TIMESTAMP
           END-EXEC
      *    or alternatively
      *    EXEC SQL
      *      SELECT CURRENT TIMESTAMP INTO :ZW-TIMESTAMP
      *      FROM SYSIBM/SYSDUMMY1
      *    END-EXEC

...
This delivers me a current timestamp in this format
Code:
ZW-TIMESTAMP = '2011-12-16-11.44.05.671308'
from which I can extract the time needed.
 
Hello mikrom,

thank you very much.
That is the solution.

Only the SQL-function is different, because we work with ORACLE :

SELECT SYSTIMESTAMP INTO :ZW-TIMESTAMP FROM DUAL

Matzi
 
Hi Matzi,

IMHO, using SQL timestamp is the simplest way to go, however in my practice I never needed thousands of seconds: the hundreds delivered by the COBOL intinsic function CURRENT-DATE were adequate.

I have experience only with DB/2: I thought that CURRENT TIMESTAMP is SQL standard and wondered how an SQL-function can consist of 2 words. Now I know that it isn't standard, when Oracle has SYSTIMESTAMP function for it.
 
The ANSI SQL standard is the LOCALTIMESTAMP function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
In the old days I used to create DATETIME routines which get the differences between two dates(for aging-trial balances), get days of the week or months, etc. The routines are basically used for cobol machines that does not have intrinsic functions like Tandem. It's just a simple trick of converting date/time into microseconds.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top