title: how to get the microsecond portion of GetSystemTimePreciseAsFileTime/ " cLngLng of FileTime"
body: <p>Spring boarding off of Gustav's comments(Thanks, G) and another hour of searching, if someone can get me started on how to convert filetime to VBA LongLong, I'm confident I can handle it from there.  There are examples of C++ FileTime two part variable to Quadword etc, but I know nothing about C++ so cannot mimic this in VBA.</p>
  <p>Example in C++ is Stack Overflow question:  <a href="https://stackoverflow.com/questions/1566645/filetime-to-int64">FILETIME to __int64</a>, scroll down to &quot;Performing Arithmetic with File Times&quot;</p>
  <p>Essentially if I can get a custom cLngLng in VBA to handle FileTime input, I should be good to go.</p>
  <p>Original Post:</p>
  <p>I'm looking at accuracy of various time stamps in VBA, but hit a roadblock on using GetSystemTimePreciseAsFileTime.  Apparently it gives a UTC type timestamp with a resolution of 100nSec in FileTime format.  I cant figure out how to extract the last four decimal places of the seconds portion.  If I use FileTimeToSystemTime it truncates the time to S.000 accuracy.  I want to look at the rest of the GetSystemTimePreciseAsFileTime time stamp, i.e look at the seconds portion to the full S.0000000 resolution.</p>
  <p>I was hoping I could extract the data and insert into Excel spreadsheet to let me figure this out..code works in saving the timing data, but I'm stuck.  You can see the changes to FileTime.dwLowDate when you convert from file time to system time back to file time...is there a way to look at the changes to dwLowDate that tell you what the last four decimal places are?</p>
  <p>Code so far is below. Plus of course the appropriate declarations and kernal32 subs and functions.
  Some of my reading suggests I might have to use &quot;quadpart&quot;, whatever that is, as part of my calculations.  Haven't been able to find out how to use quadpart or even if it exists in VBA.</p>
  <p>Can someone steer me in the right direction to get the full resolution of the GetSystemTimePreciseAsFileTime?</p>
  <pre><code>Sub TestPrecisionTime()
  
  Dim FileTimePercision As FileTime
  Dim FileTimeBack As FileTime
  Dim LocalSystemTime As SYSTEMTIME
  Dim res As Long
  
  GetSystemTimePreciseAsFileTime FileTimePercision  'Get the precision 100nSec system time
  'convert it to System Time
  res = FileTimeToSystemTime(lpFileTime:=FileTimePercision, lpSystemTime:=LocalSystemTime)
  'Convert it back to FileTime to see what has changed from FileTimePercision.dwLowDateTime
  res = SystemTimeToFileTime(lpSystemTime:=LocalSystemTime, lpFileTime:=FileTimeBack)
  
  'Save the results so can try to develop algorithm to extract the last four digits of the time
  'seconds down to 100 nsec, so S.0000000 &quot;format&quot;, System time only gives S.000 &quot;format&quot;
  
  Dim appAnalysis As Application
  Dim wbPrecisionTime As Workbook
  Dim wsPrecise As Worksheet
  Dim sControlWB As String
  If appAnalysis Is Nothing Then Set appAnalysis = Application
  sControlWB = ActiveWorkbook.Name
  If wbPrecisionTime Is Nothing Then Set wbPrecisionTime = appAnalysis.Workbooks(sControlWB)
  If wsPrecise Is Nothing Then Set wsPrecise = wbPrecisionTime.Sheets(&quot;Precise&quot;)
  
  With wsPrecise
              .Range(&quot;A2&quot;) = FileTimePercision.dwLowDateTime
              .Range(&quot;B2&quot;) = FileTimePercision.dwHighDateTime
              .Range(&quot;C2&quot;) = FileTimeBack.dwLowDateTime
              .Range(&quot;D2&quot;) = FileTimeBack.dwHighDateTime
              .Range(&quot;E2&quot;) = LocalSystemTime.wYear
              .Range(&quot;F2&quot;) = LocalSystemTime.wMonth
              .Range(&quot;G2&quot;) = LocalSystemTime.wDayOfWeek
              .Range(&quot;H2&quot;) = LocalSystemTime.wDay
              .Range(&quot;I2&quot;) = LocalSystemTime.wHour
              .Range(&quot;J2&quot;) = LocalSystemTime.wMinute
              .Range(&quot;K2&quot;) = LocalSystemTime.wSecond
              .Range(&quot;L2&quot;) = LocalSystemTime.wMilliseconds
  
  End With
  End Sub
  </code></pre>