[AccessD] Time in milliseconds

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jun 24 00:21:03 CDT 2003


On 23 Jun 2003 at 21:08, Rocky Smolin - Beach Access S wrote:

> Dear List:
> 
> Is it possible to access/store/display the time in increments smaller than seconds.  I need to time something in fractions of a second.
> 


Short answer -  Yes.

Slightly longer answer - Yes but you can't use the built in formatting functions.

Long answer -   

It depends on exactly what you are trying to do.


Store:
Dates and Times are actually stored as doubles with the time as the fractional part so times can certainly be stored to far 
greater accuracy than seconds.  

Display:
To display fractional seconds within a date/time format, you will need to roll your own formatting function since there is 
no decimal seconds formatting character. 

If you just want to display a number of seconds, use  a numeric variable for the number of seconds, then you can format 
it to any precision you want ( or again roll your own format by working in seconds and calcuating hours,minutes etc as 
required)


Measure:
If you are trying to time events of a reasonable duration. use the TIMER() function . It returns a double representing the 
number of "ticks" elapsed sinced midnight. A tick is approximately 1/18th  sec. 

For higher resolution, use the GetTickCOunt() API function which *nominally* returns the number of milliseconds since 
the system started. The actual resolution is dependant on the particular system, you can determine what it is using the 
GetSystemTimeAdjustment() API call, but it's normally good to about 1/100th sec

If you are timing short durations and need even high accuracy, you can use the high-resolution performance counter
(if your machine has one) and get possibly better than millisecond and maybe even close to microsecond accuracy
(let me know if you want a copy of an ElapsedMicroSeconds() function which uses the hrpc API calls.


-- 
Stuart McLachlan
Lexacorp Ltd
Application Development,  IT Consultancy
http://www.lexacorp.com.pg



More information about the AccessD mailing list