내 도메인 컴퓨터의 lastlogon 필드를 내 보내야합니다. 나는이 명령을 사용했다 :
dsquery * domainroot -filter "(&(objectCategory=Computer)(
objectClass=User))" -attr distinguishedName sAMAccountName lastLogon
이것은 txt 파일로 내보내졌습니다. 내 문제는 lastlogon 필드가 정수 타임 스탬프이며 실제로 날짜가 아니라는 것입니다. 예를 들어 이것은 130931011681543000 값 이지만이 값을 날짜로 인식 할 수 없습니다. 이것은 unixtimestamp가 아니며 1900/1/1의 millis입니다 …이 값을 읽을 수있는 날짜로 변환하는 방법은 무엇입니까?
답변
FILETIME 객체이며 Excel 매크로를 사용하여 변환 할 수 있습니다.
옵션 명시
개인 유형 FILETIME dwLowDateTime as Long dwHighDateTime as Long End 유형
개인 유형 SYSTEMTIME 정수로 표시 정수로 wMonth 정수로 wDayOfWeek 정수로 정수 정수로 정수 w 소수로 정수 w 초로 정수 w 밀리 초 정수로 끝 유형
개인 선언 함수 FileTimeToSystemTime Lib “kernel32″(lpFileTime은 FILETIME, lpSystemTime은 SYSTEMTIME)
Function ConvertDate(test)
ConvertDate = Bit64ToDate(test)
'4/26/2010 8:32:27 PM
End Function
Private Function Bit64ToDate(Bit64) As Date
Dim High As Long, Low As Long, ft As FILETIME, st As SYSTEMTIME
GetTwoLongsFromInt64 [Bit64], ft.dwHighDateTime, ft.dwLowDateTime
FileTimeToSystemTime ft, st
Bit64ToDate = SystemTimeToVBTime(st)
End Function
'the following function - thanks to
'http://doc.xceedsoft.com/products/Xceedzip/64_bit_values.html
Private Sub GetTwoLongsFromInt64(ByVal cInt64 As Double, ByRef lHigh As Long, ByRef lLow As Long)
Dim cRemainder As Double
lHigh = CLng(Fix(cInt64 / 4294967296#))
cRemainder = cInt64 - (lHigh * 4294967296#)
If (cRemainder <= 2147483647#) Then
lLow = CLng(cRemainder)
Else
cRemainder = cRemainder - 4294967296#
lLow = (CLng(cRemainder))
End If
End Sub
'the following function - thanks to
'http://www.cpearson.com/excel/FileTimes.htm
Private Function SystemTimeToVBTime(SysTime As SYSTEMTIME) As Date
With SysTime
SystemTimeToVBTime = DateSerial(.wYear, .wMonth, .wDay) + _
TimeSerial(.wHour, .wMinute, .wSecond)
End With
End Function