I have the following C# that is giving me the error above when trying to parse string to datetime.
DateTime backupdate = System.Convert.ToDateTime(imageflowlabel.Text);
DateTime currentdate = System.DateTime.Now.AddHours(-2);
int result = currentdate.CompareTo(backupdate);
imageflowlable.text looks like this 2012-04-15 15:23:34:123
Any ideas on how to convert this?
Thanks
Yes – use “DateTime.ParseExact()” or “TryParseExact()” with a custom format string:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx