SPListItem.Properties DateTime field is in strange Hex format

Does anyone know how to convert these hexadecimal string values ​​to DateTime values?

Property my_DateProperty (System.String) = 0x01c9874e | 0x98f28800

//l_item is SPListItem Hashtable l_properties = l_item.Properties; if (l_properties != null) { object l_value = null; foreach (string l_key in l_properties.Keys) { l_value = l_properties[l_key]; Splogger.log("Property " + l_key + " (" + l_value.GetType().ToString() + ") = " + l_value.ToString()); } } 
+3
source share
2 answers

I recently discovered that this only happens in Office 2007 documents (for other file types, this is the standard string format for dates). The answer is that the hexadecimal value represents the number of ticks from 1/1/1600. Here is the conversion that worked for me:

Dim dateVal as DateTime = New DateTime (Long.Parse (dateText.Replace ("0x", ") .Replace (" | "," "), System.Globalization.NumberStyles.HexNumber)). AddYears (1600)

+7
source

It may be that the date-time is converted to the "invariant" date of ToString. See this .

0
source

All Articles