|
I agree that it's a cool thing to have all 6 microseconds filled in. But to do that, now I need to make my program SQLRPGLE rather than RPGLE, correct? And now editing doesn't work as well in WDSc. And unless I'm at V5R4, I have to use fixed format for the SQL statements (yes, I know the goodness of subroutines).
Here's an example of retrieving the full timestamp (to the microseconds) that does not use SQL at all. Granted, it requires a little more code, but you can easily stick that routine into a service program, and use it whenever you need it.
H DFTACTGRP(*NO)
D GetMicroTime PR Z
D ts s Z
D wait s 1A
* The time op-code only returns milliseconds
c time ts
c ts dsply wait
/free
// the timestamp BIF also only returns millisecs
ts = %timestamp();
dsply ts '' wait;
// the gettimeofday() API returns microseconds!
ts = getMicroTime();
dsply ts '' wait;
*inlr = *on;
/end-free
P GetMicroTime B
D GetMicroTime PI Z
D CEEUTCO PR
D hours 10I 0
D minutes 10I 0
D seconds 8F
D fc 12A options(*omit)
D gettimeofday PR 10I 0 extproc('gettimeofday')
D time like(timeval)
D timezone 8a options(*omit)
D timeval ds
D tv_sec 10I 0
D tv_usec 10I 0
D RetVal s Z inz(z'1970-01-01-00.00.00')
D hours s 10I 0
D mins s 10I 0
D FSecs s 8F
D Secs s 20P 0
/free
CEEUTCO(hours: mins: fsecs: *omit);
secs = fsecs;
gettimeofday( timeval: *omit );
Retval = Retval + %seconds(tv_sec)
+ %seconds(secs)
+ %mseconds(tv_usec);
return retval;
/end-free
P E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.