×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# How to return time value to thousandths of a second?

## How to return time value to thousandths of a second?

(OP)
I'm converting a heap of Assembler programs to MF Cobol, one of which uses the BAL "TIME" macro to get the system time in format hhmmssttt.
I'm using the COBOL FUNCTION CURRENT-DATE to do the same, but this only returns time to a precision of hhmmsshh.

Is there any way of getting more precision out of the function, chaps?

### RE: How to return time value to thousandths of a second?

(OP)
Sorry, Frederico!
Cobverting BAL from IBM Enterprise System to COBOL on Windows PC using MicroFocus Mainframe Express (MF COBOL), v3.1

### RE: How to return time value to thousandths of a second?

I don't know about thousandth of a seconds but in Tandem system I usually use micro seconds (millionth of a second)
which is 1000000 micro seconds. A practical usage is when you are trying to find the days or time differences between two dates and time. You simply convert hours, minutes and seconds
into micro seconds then add all the micro seconds.

Here's some numbers (it's been a long time so I hope it is the correct conversion):

Hours * 3600000000 = total micro seconds in an hr.
Minutes * 60000000 = total micro second in a minute.
Seconds * 1000000  = total micro seconds in a second.

Your working storage should be like PIC 9S(18) COMP.

### RE: How to return time value to thousandths of a second?

You might want to use LE callable services to get the local time in YYYYMMDDHHMMSS999 format (CEELOCT).  Check the LE programming guide for details.

Regards,

Glenn

### RE: How to return time value to thousandths of a second?

A millisecond is only 1,000 microseconds.  By definition.

### RE: How to return time value to thousandths of a second?

(OP)
Thanks to all who responded.

3gm, I have tried the CEELOCT option (have to set LE environment option to enable), but actually this cheats a little, and the CEELOCT program code always inserts a zero in the thousandths position. It therefore returns the same precision as the ACCEPT or FUNCTION methods, it only appears at first glance to be more precision?

I'm currently experimenting with the WINAPI functions such as "GetSystemTime" etc. these appear a little better, but apparently the Windoze hardware tends to jump in iuncrements of several thousandths of a second. Guess it just doesn't think anybody would want more precision?

I'll plough on, but this appears to be a problem that many people have found in the past, and it depends on your platform as to which options are available (e.g. Unix has a diffenent environmental function)

### RE: How to return time value to thousandths of a second?

Hi There,

IIRC - The intrinsic FUNCTION CURRENT-DATE in Enterprise COBOL can give you resolution up to 100th of a second.

#### Quote:

Guess it just doesn't think anybody would want more precision?
How is one more digit of precision needed for this requirement?

If you really, really must, suggest you consider an assembler STCK (or STCKE if you want to cover the STCK overflow in 2042).

### RE: How to return time value to thousandths of a second?

#### Quote:

I'm currently experimenting with the WINAPI functions such as "GetSystemTime" etc. these appear a little better, but apparently the Windoze hardware tends to jump in iuncrements of several thousandths of a second. Guess it just doesn't think anybody would want more precision?

I don't know precisely what your programs are looking to do, but if you're timing something, GetSystemTime isn't what you want.  All it's good for is getting the date and time out of the system into your program, and from the comment you made, I guess that's NOT what you're doing.

These two are what you want if you want to time stuff:
QueryPerformanceFrequency
QueryPerformanceCounter

and if worse comes to worse and you're on a 9X series box, use:

timeGetTime

Measurement is not management.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!