Problem with Linq query and date format
Posted
by Alan T
on Stack Overflow
See other posts from Stack Overflow
or by Alan T
Published on 2010-06-16T16:00:02Z
Indexed on
2010/06/16
16:02 UTC
Read the original article
Hit count: 398
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
© Stack Overflow or respective owner