Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Timestamp (Access2000)

    In Access you can have the hour, minute, and second with the now function. I would like to know if I can get down to millisecond or not.

    thanks

  2. #2
    New Lounger
    Join Date
    Jul 2001
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Timestamp (Access2000)

    dont think so !

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Millisecond Timestamp (Access2000)

    Access won't do it, but you can use an API function. The Date data type will only go down to the second, so you'll probably want to use a separate field to store the millisecond. Paste this into a module:<pre>Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
    Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
    End Type
    Function GetMilliseconds() As Integer
    Dim MyTime As SYSTEMTIME
    GetLocalTime MyTime
    GetMilliseconds = MyTime.wMilliseconds
    End Function</pre>

    Just call the GetMilliseconds() function to return an integer of the current time in Miliseconds.

    The only trouble is that this function will give you the current time in milliseconds as of the time it's called. There could be a small delay from the actual time a executes the command and the time this function executes.

    I would recommend placing this function as the first item that executes in order to give it the most accurate value. Then, include the normal Now() function to give hour, minute, and second.

    HTH <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Millisecond Timestamp (Access2000)

    Thanks Mark,

    It works perfectly!

    Simon

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Timestamp (Access2000)

    Why do you require accuracy down to millisecond?
    If you require an absolute time you could end up comparing the clock settings of different PC's.
    If you require to time a very small interval then don't forget Windows is not a real time operating system. By that I mean you can not be certain that Windows does not perform other tasks inbetween your two time stamps that makes it appear the overall time taken is longer than the real time taken for the operation you measure. Also VBA is not exactly built for performance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •