Hi,
I a hex value 0x00009B9300E313F9 whose equivalent date time value is
Jan 16 2009 13:46:45.950 .i got this hex value after raw reading an .mdf file of sql server 2000
the sql datatype of this value is "datetime"
can somebody please help me convert this hex value to date-time using c++
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.
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.
Bookmarks