× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Y'all

I lost the chain where Booth, I think, was looking at some aspects of the timestamp functions on the system. I responded that fractional seconds are easily obtained using the "current timestamp" special SQL register - so I thought I'd better test things. Bruce had already done some of this, I hope this isn't superfluous.

No matter what I did, the %timestamp BIF resolves only to milliseconds. In the example below, they are all equal - because it ran so quickly.

The SQL approach resolves to as many fractional seconds as the target variable allows. This is what I would use if I needed the finest granularity, for uniqueness, I believe.

I didn't test the QWCCVTDT API, which, however, is limited to microseconds = 6 fractional seconds, as Bruce pointed out. The additional uniqueness digits, IIRC, are available using an MI function, MATTOD - it's been awhile since playing with this, so I might have it slightly off.

Here is the code -

       dcl-s tstmp06 timestamp;
       dcl-s tstmp12 timestamp(12);
       dcl-s tstmp06from12 timestamp;
       dcl-s tstmp12from06 timestamp(12);

       dcl-s tstmp06sys timestamp;
       dcl-s tstmp12sys timestamp(12);

       dcl-s tstmp06s timestamp;
       dcl-s tstmp12s timestamp(12);
       dcl-s tstmp06sfrom12 timestamp;
       dcl-s tstmp12sfrom06 timestamp(12);

       // Use BIF timestamp alone
       tstmp06 = %timestamp;
       tstmp12 = %timestamp(*sys : 12);
       tstmp06from12 = %timestamp(*sys : 12);
       tstmp12from06 = %timestamp;

       // Use *SYS in BIF
       tstmp06sys = %timestamp(*sys : 6);
       tstmp12sys = %timestamp(*sys : 12);

       // Use SQL current timestamp
       exec sql
         set :tstmp06s = current timestamp;
       exec sql
         set :tstmp12s = current timestamp(12);
       exec sql
         set :tstmp06sfrom12 = current timestamp(12);
       exec sql
         set :tstmp12sfrom06 = current timestamp;

       *inlr = *on;

Here're the results -

> EVAL tstmp06
  TSTMP06 = '2019-12-08-04.04.22.647000'
> EVAL tstmp12
  TSTMP12 = '2019-12-08-04.04.22.647000000000'
> EVAL tstmp06from12
  TSTMP06FROM12 = '2019-12-08-04.04.22.647000'
> EVAL tstmp12from06
  TSTMP12FROM06 = '2019-12-08-04.04.22.647000000000'
> EVAL tstmp06sys
  TSTMP06SYS = '2019-12-08-04.04.22.647000'
> EVAL tstmp12sys
  TSTMP12SYS = '2019-12-08-04.04.22.647000000000'
> EVAL tstmp06s
  TSTMP06S = '2019-12-08-04.04.22.647548'
> EVAL tstmp12s
  TSTMP12S = '2019-12-08-04.04.22.647802819335'
> EVAL tstmp06sfrom12
  TSTMP06SFROM12 = '2019-12-08-04.04.22.647935'
> EVAL tstmp12sfrom06
  TSTMP12SFROM06 = '2019-12-08-04.04.22.648147000000'

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.