collection ERROR: The string was not recognized as a valid DateTime

Mar 10, 2010 at 10:28 PM


SQLH2 stopped collecting data for many servers three months ago.

For these servers, SQLH2 log has entries like:

   at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.DateTime.Parse(String s)
   at H2V2.Collector.SystemLogEvent..ctor(EventLogEntry a_entry)
   at H2V2.Collector.CollectorEventLog.CollectSystem()
   at H2V2.Collector.CollectorEventLog.UnitCollectSystem()
3/10/2010 12:34:22 PM           ERROR:           String was not recognized as a valid DateTime.
3/10/2010 12:34:22 PM           ERROR:           Unit 1 failed
after researching i found that it might not be parsing date/time like it should be. My sources mentioned inorder to parse datetime correctly you should use one of the following:
 System.DateTime str_date=DateTime.Parse(sel3.Text,System.Globalization.CultureInfo.CreateSpecificCulture("en-AU").DateTimeFormat);

DateTime dt = DateTime.Parse(dtString,

Instead of DateTime.Parser use Convert.ToDateTime(string date).
If I change the C# source code according to the recommendations, would it just work? Or do I have to do something else?
Thanks in advance
Mar 13, 2010 at 1:15 AM

If you set it to a particular Culture, it will only work for that Culture, so I don't think it's a solution.

You can debug to see where exactly it breaks. As I see it breaks why reading System EventLog. I think there is an event somewhere that contains a date in the wrong format. You local date format (on Collector machine) is obviously MDY. If you have a target server that uses different date format it could lead to this problem. Where Collector is able to read dates from binary data it's fine. Actual event timestamp in the log is read in binary format. However some events write dates as strings into messages, which we try to read and analyze. That could be a reason for such an error.