I have minor problem with retrieving data from MS ACCESS database with SELECT - WHERE statement. I want to get certain rows based on date.
Here is the code:
|
This part of code works but only without WHERE clause. With WHERE clause i get this error:
Syntax error in date in query expression 'Datum = #3.4.2010.'
3.4.2010 is value of date variable above in code. I don't know what to anymore i tried without #, but this doesn't work too...
Please give me a hand....
Thanks in advance.... Neven
mamoon qasimPosted Apr 4, 2010, 1:37 PM
NevenPosted Apr 5, 2010, 8:28 AM
But I solved problem in other way. The problem was due to localization.
In my country the normal date format is "dd.mm.yyyy" and in that format, dispite HR (Croatia) local settings on my computer that query didn't work for given format.
However i found out in some tutorial that "universal" date format for MS Access is "yyyy-mm-dd". I simply added 2 lines of code to my program and voila, it worked.
string date="21.12.2012";
DateTime dateX = Convert.ToDateTime(date);
//Transforms to "universal" form
date = dateX.Year + "-" + dateX.Month + "-" + dateX.Day;