Problem with Linq query and date format
- by Alan T
Hi All
I have a C# console application written using Visual Studio 2008.
My system culture is en-GB. I have a Linq query that looks like this:
var myDate = "19-May-2010";
var cus = from x in _dataContext.testTable
where x.CreateDate == Convert.ToDateTime(myDate)
select x;
The resulting SQL query generates and error because it returns the dates as "19/05/2010" which it interprets as an incorrect date. For some reason even though my system culture is set to en-GB it looks like it's trying to intrepret it as a en-US date.
Any ideas how I get around this?
Thanks.
Alan T