Comparing date in C # state with oledb database

I have to take 2 values ​​from DateTimePicker and then compare their values ​​in the database.

Code:

string dt_start = dateTimePicker1.Value.ToShortDateString();
string dt_end = dateTimePicker2.Value.ToShortDateString();
string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between " + dt_start + " and " + dt_end + " ";

      

It doesn't show any error, but I am not getting output values.

+3


source to share


2 answers


Access uses # for dates. This should work:



string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between #" + dt_start + "# and #" + dt_end + "#";

      

+3


source


try the following select statement:



string mySelectQuery = "Select * from " + out_table + " WHERE [Date] Between '" + dt_start + "' and '" + dt_end + "' ";

      

0


source







All Articles