Hex Date Format

I get a hexadecimal string when converting the SPListItem date.

eg. "0x01c9d2be | 0x809a8800"

This question answers it.

However, what is the correct way to convert it, in what format is the DateTime object located? What if I want to set a date-time? Should I convert it to hexadecimal and assign it as the sixth line?

There should be a better and perfect way to retrieve a DateTime object.

Any ideas?

Thanks.

+4
source share
3 answers

I can extract the date and time. It's fine.

So when you change the DateTime ListItem, you just simply assign it as a DateTime format, and it will interpret it correctly; no need to generate the hex which it returns.

+3
source

The DateTime value in .NET can also be represented as a 64-bit value. The strange format of the string in DateTime fields in SharePoint list items is a variant of such a 64-bit value encoded as two 32-bit hexadecimal values. In this format I did not find documentation from Microsoft. But by trial and error, I found the following conversion method:

string[] words = strVal.Split('|'); int high = int.Parse(words[0].Substring(2), System.Globalization.NumberStyles.HexNumber); uint low = uint.Parse(words[1].Substring(2), System.Globalization.NumberStyles.HexNumber); long ticks = high; ticks = ticks << 32; ticks += low; DateTime t = new DateTime(ticks); t = t.AddYears(1600); 

where t has a result.

+2
source

Another solution can be found here. Is there something to do when Office 2007 stores dates .. SPListItem.Properties The DateTime field is in a strange Hex format

+1
source

All Articles