how to convert FILETIME to a vb date time 
Author Message
 how to convert FILETIME to a vb date time

I would like to display the date and time from WIN32_FIND_DATA
ftLastWriteTime. How do I do it in VB?

Thanks Julia



Sun, 02 Jun 2002 03:00:00 GMT  
 how to convert FILETIME to a vb date time
Julia,
    I just wrote almost the same exact code yesterday.
Here's an excerpt (w/o the declarations):

Public Function FileCreateDate(ByVal Pathname As String) As Date
'*****************************************************************
'* Gets the date and time that a file was created on             *
'*****************************************************************
  Dim lngHFindFile As Long
  Dim udtSystemTime As SYSTEMTIME
  Dim udtWIN32_FIND_DATA As WIN32_FIND_DATA
  Dim udtTIME_ZONE_INFO As TIME_ZONE_INFORMATION
  Dim dteTemp As Date

  'find file
  lngHFindFile = FindFirstFile(Pathname, udtWIN32_FIND_DATA)
  'close find
  Call FindClose(lngHFindFile)
  'convert the file time to system time
  Call FileTimeToSystemTime(udtWIN32_FIND_DATA.ftCreationTime,
udtSystemTime)
  'get time zone information
  Call GetTimeZoneInformation(udtTIME_ZONE_INFO)
  'convert the file time (which is now in system time format) to the
local time
  Call SystemTimeToTzSpecificLocalTime(udtTIME_ZONE_INFO,
udtSystemTime, udtSystemTime)
  'convert the file time to Visual Basic's Date data type
  With udtSystemTime
    dteTemp = DateSerial(.wYear, .wMonth, .wDay) + TimeSerial(.wHour,
.wMinute, .wSecond)
  End With

  FileCreateDate = dteTemp

End Function

BTW, if all you want is the last modified date, you can use
FileDateTime instead.

- Jim



Quote:
> I would like to display the date and time from WIN32_FIND_DATA
> ftLastWriteTime. How do I do it in VB?

> Thanks Julia

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 02 Jun 2002 03:00:00 GMT  
 how to convert FILETIME to a vb date time

Quote:
>I would like to display the date and time from WIN32_FIND_DATA
>ftLastWriteTime. How do I do it in VB?

Julia,

Convert it from FILETIME fo Date using one of these methods:

FileTimeToLocalFileTime -> FileTimeToSystemTime ->
SystemTimeToVariantTime

- or -

FileTimeToSystemTime -> SystemTimeToTzSpecificLocalTime ->
SystemTimeToVariantTime

You can find all declares in the API Viewer, except
SystemTimeToVariantTime.

Private Declare Function SystemTimeToVariantTime Lib "oleaut32.dll"
(lpSystemTime As SYSTEMTIME, pvtime As Date) As Long

Mattias

________________________________________________
Mattias "beezo" Sj?gren, MCP

http://home1.2.sbbs.se/mattias.sjogren/sw/
Please send questions/replies to the newsgroups



Sun, 02 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Converting %date% %time% to VB Time/Date

2. Convert FILETIME TO DATE DATA TYPE IN VB5

3. Get Date and Time from Filetime

4. How to Convert GMT(Greenwich) Time to short date and time and vice versa

5. Compare date in form with date/time in form with date/time in database

6. VB Date/Time datatype and VB date functions

7. How to convert a unix time_t to win32 filetime in Visual basic

8. VB Date/Time datatypes and VB date functions

9. How to convert a unix time_t to win32 filetime in Visual basic

10. How to convert a UNIX FILETIME to a usable Date/Time?

11. How to assign date value to FILETIME structure

12. FileTime to DOS Time

 

 
Powered by phpBB® Forum Software