Focal Point
[CLOSED] How to get Time at nanosecond level

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8407053426

September 21, 2012, 02:00 PM
DW Marker
[CLOSED] How to get Time at nanosecond level
All,

Have tried searching and for the life of me I can't determine how to get the time at a nano-second level. Need this as we have a servlet which during a single session may be called multiple times within a minute with different inputs. Regular hold files appear to be fine of course, but we have a part of this that has to use -WRITE commands, and that file needs to be unique, to avoid conflicting processes writing to the same file.

This message has been edited. Last edited by: Kerry,


WF 7.6.4
Windows XP and UNIX
September 21, 2012, 02:49 PM
Prarie
Acording to this document you can convert with a lengh of 12 and it will include nanoseconds.
Don't know if this will work in your case.

nano
September 21, 2012, 03:28 PM
DW Marker
I want to do this against current time, so how do I get the current time (including nano-seconds)


WF 7.6.4
Windows XP and UNIX
September 21, 2012, 04:38 PM
Francis Mariani
Unfortunately, though you can get the Date-Time with nano seconds, the nano seconds are zero:

TABLE FILE CAR
PRINT 
COUNTRY NOPRINT
COMPUTE CURRDTTM/HYYMDn = HGETC(12, 'HYYMDn');
WHERE RECORDLIMIT EQ 1
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS H001 FORMAT ALPHA
END
-RUN

-READ H001 &CURRDTTM.A23.
-SET &CURRDTTM= EDIT(&CURRDTTM,'9999/99/99 99:99:99.99999999');

-TYPE &CURRDTTM



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 21, 2012, 04:50 PM
Dan Satchell
Based on documentation, this would supposedly return number of nanoseconds:

-SET &CURR_NANOS = HPART(HGETC(17,'H17'),'nanosecond','I9');
-TYPE &CURR_NANOS



WebFOCUS 7.7.05
September 22, 2012, 02:41 AM
DW Marker
Dan,

Thanks for getting me on the right track, and Francis thanks for pointing out that nanos come back as 0. I can use microseconds along with a random number to virtually guarantee that I won't have a repeated "key" during the same timeframe.

Thanks Again for your help


WF 7.6.4
Windows XP and UNIX
September 23, 2012, 10:37 AM
j.gross
DWM:

Last time I experimented, it appeared that WF used current time to the *second* as the random-number-generator seed. If that is so, you'll gain nothing (in terms of uniqueness) from appending a "random" value to the ms-granular time
September 23, 2012, 05:35 PM
Waz
The other option is to use the TSCom Id.
-SET &Temp = FGETENV(7,'EDATEMP',80,'A80') ;
-SET &Temp = TRUNCATE(&Temp) ;

-SET &TSCom = EDIT(GETTOK(&Temp,&Temp.LENGTH,-1,'\',8,'A8'),'$$999999') ;
-TYPE &TSCom


The delimiter may have to change depending on the OS.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 24, 2012, 04:40 AM
Alan B
quote:
-SET &CURR_NANOS = HPART(HGETC(17,'H17'),'nanosecond','I9');
-TYPE &CURR_NANOS


This will not work unfortunately, only accurate to the nearest tenth in reality. The HGETC 'clock' appears to increment in .015/.016 second steps.

The microsecond part is always 232 and the nanosecond part is always 224.


Alan.
WF 7.705/8.007
September 24, 2012, 05:32 PM
Waz
I think the nanosecond support depends on the OS.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!