Query returns 0 rows..
Hello
My problem is pretty straightforward, the following query returns nothing:
oleDbCommand2.CommandText="SELECT Orders.OrderID FROM Orders WHERE Orders.CustomerID='"+cusID+"' AND (Orders.OrderDate BETWEEN "+startDate+" AND "+endDate+")";
However, when I remove the "AND Orders.OrderDate BETWEEN..." part, my query works fine. Any ideas on what could be the problem? And yes, I've checked that the database does contain rows for those dates.
Thanks!
agus_ayalaPosted Apr 6, 2006, 5:27 AM
Hope this helps:
mycommad.CommandText = "SELECT Orders.OrderID FROM Orders WHERE Orders.CustomerID='"+cusID+"' AND (Orders.OrderDate BETWEEN '"+startDate.ToString("yyyy-MM-dd")+"' AND '"+endDate.Tostring("yyyy-MM-dd")+"')";
Is better do this conversion of the datetime to put it on sql server date standard year-month-day.
Cheers,
Agus