I’m using MySQL Connector to retrieve data from a mySQL database to a .NET app.
Here’s my code :
DateTime syncStart = ....
DateTime syncFinish = ....
string Sql = "select * from orders where created_on > @SYNC_START_DATE and created_on <= @SYNC_FINISH_DATE"
myCommand = new MySqlCommand(Sql, conTrace);
myCommand.Parameters.AddWithValue("@SYNC_START_DATE", syncStart);
myCommand.Parameters.AddWithValue("@SYNC_FINISH_DATE", syncFinish);
myDataReader = myCommand.ExecuteReader();
This query should return a bunch of rows, but instead the reader returns nothing
I’ve tried this query but insted filtering by date, I’ve filtered by id, binding the parameters in the same way and this worked.
It seems that it doesn’t work when I use dateTime parameters.
Can anybody help me with this problem ?
Thanks!
You should use
between:http://www.w3schools.com/sql/sql_between.asp