Re: Hex value to date time
Convert the hex value to a __uint64 and pass it to the constructor of COleDateTime.
Re: Hex value to date time
thanks for replying,
I tried using Coledatetime in following manner : -
LONGLONG t = 0x00009B9300E313F9;
//t = 171055677379577(decimal value)
CString buffer;
SYSTEMTIME st;
FILETIME FileTime;
FileTime.dwLowDateTime = (DWORD) t;
FileTime.dwHighDateTime = (DWORD)(t >> 32);
FileTimeToSystemTime(&FileTime,&st);
COleDateTime* startOnDate = new COleDateTime(st);
buffer = startOnDate->Format(_T("%d-%b-%Y"));
It gives me o/p as 17-Jul-1601 where as it should be Jan 16 2009
the datetime value as viewed in hex editor is f913e300 939b0000 i converted it
in little endian form to get 00009B9300E313F9.
What can i do next?
Re: Hex value to date time
The 4 bytes of the sql datetime is the number of days since 1900-1-1. The second 4 bytes is the miliseconds since midnight. You can convert the values like this
Code:
int date_part = 0x00009B93;
int time_part = <time value here> / 1000;
COleDateTime startOnDate(1900, 1, 1, 0, 0, 0);
startOnDate += COleDateTimeSpan(date_part, 0, 0, time_part);
CString buffer = startOnDate.Format();
The location of the date 0x00009B93 is ok but your time should be the next 4 bytes after the days location. Check your .mdf file and use the 4 bytes after 0x00009B93 as time.
Hope it will help
Re: Hex value to date time
hi thanks for replying and for sharing these useful information.
The date part is giving me the right ans which is 16-01-2009
however the time is still incorrect.
the 4 bytes associated with time is 0x00e313f9 (little endian form).
The time should be 1:46PM where as i am getting the ans as 4:08:01 AM.