Query problem with c#

udigold1

New member
Local time
Yesterday, 16:12
Joined
Dec 19, 2010
Messages
2
Hi,

I have a c# form in which I retrieve data from Access DB.
I have Two DateTimePickers so I could choose data between dates.
My problems is when I try to retreive data between 19/10/2010 and 12/12/2010 it gives me me data beyond 12/12/2010 but when I try to retreive data between 9/12/2010 and 12/12/2010 it works fine.

here's my query:


  1. "select DateId, NiarDesc, ManagerId, RateText, QuantityVal, ActionID From tbl1_order
  2. where DateValue(DateId) between "'19/10/2010' and '12/12/2010'";

i also tried to do it with getting the dates form the datetimepicker:

C# Syntax


  1. "select DateId, NiarDesc, ManagerId, RateText, QuantityVal, ActionID From tbl1_order
  2. where DateValue(DateId) between "' + datepicker1.Value.ToShortDateString + '" +
  3. " and '" + datePicker2.Value.ToShortDateString +"'";


It seems that it ignores the month value and considers only the day value.
Why this is happening?

Thanks,
Udi
 
Normally dates are surrounded with # signs. What is being stored in DateId? is this a number (julien date)?
 
With queries and MS Access, you need to send criteria to it using US Date format or a non-ambiguous format. See here for more about that.
 

Users who are viewing this thread

Back
Top Bottom