Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpret UInt64 dateData in .NET DateTime structure?

In looking at a DateTime struct in the debugger via SOS.dll, I see...

  0:096> !DumpVC 000007feed1ddff8  000000028036d890 
  Name:        System.DateTime
  MethodTable: 000007feed1ddff8
  EEClass:     000007feecbed6b0
  Size:        24(0x18) bytes
  File:          C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.  dll
  Fields:
                MT    Field   Offset                 Type VT     Attr            Value Name
  000007feed1e1158  40000d6        0        System.UInt64  1 instance 5246421159766325152 dateData

How can interpret "5246421159766325152" as a DateTime? Is there a way I can create a DateTime from this value to get the human-readable version?

like image 206
noctonura Avatar asked May 25 '12 18:05

noctonura


3 Answers

!Psscor2.PrintDateTime OBJADDR or !sosex.mdt System.DateTime DATAADDR.

like image 129
Steve Johnson Avatar answered Nov 05 '22 20:11

Steve Johnson


DateTime.FromBinary(5246421159766325152)
like image 23
Sam Axe Avatar answered Nov 05 '22 21:11

Sam Axe


If the Int64 value is in between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks, then you can call the overloaded constructor for a DateTime taking an Int64.

Your particular value falls outside of this range though. As @Boo mentioned, you can use the static DateTime.FromBinary method.

like image 1
Seth Flowers Avatar answered Nov 05 '22 21:11

Seth Flowers