Subsonic 3.0 SQLite FormatException parsing DateTime

subsonic

I have an MS Access database, which I have converted to an SQLite database. I have SubSonic setup and working, and I can pull data out of the database successfully into a WinForms app using ActiveRecord. All except for one table.

I get a FormatException, "String was not recognized as a valid DateTime". The format of the date column in the database is DD/MM/YYYY.

I'm not even trying to do anything too complicated:

 var allOrders = order.All();

 foreach (order o in allOrders)
 {
   listBox1.Items.Add(string.Format("{0} - {1}", o.OrderDate.HasValue ? o.OrderDate.Value.ToShortDateString() : string.Empty, o.Product));
 }

I'm not exactly sure why the problem is manifesting in the first place 🙁

Best Answer

SQLite has "interesting" ways of formatting dates - you have to be very, very sure that you're getting back what you think you are because normally it's not DD/MM/YYYY - it's the opposite if I recall.

Related Topic