FTtoDATE


Description:
This is a small hack that converts the Windows API FILETIME structure to a Visual Basic Date variable.
 
Code:
Option Explicit

Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type

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

Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As _
   FILETIME, lpSystemTime As SYSTEMTIME) As Long

Private Function FTtoDATE(ByRef FT As FILETIME) As Date
    
    Dim ST As SYSTEMTIME
    
    FileTimeToSystemTime FT, ST
    
    FTtoDATE = DateValue("" & Format(ST.wMonth, "0") & "/" & _
               Format(ST.wDay, "00") & "/" & Format(ST.wYear, "0000")) & _
               TimeValue(Format(ST.wHour, "00") & ":" & _
               Format(ST.wMinute, "00") & ":" & _
               Format(ST.wSecond, "00") & "")

End Function

 
Sample Usage:
 
Dim FT as FILETIME

Debug.Print "The date in FT is " & FTtoDATE(FTtoDATE(FT))