I am using C# (.NET) and SQLite database with it. I have a table in an SQLite database with a column called "InvoiceDate". I have chosen the datatype (in the db table) for the same as TEXT as I need it to be a datetime variable.
I am using the System.Data.SQLite reference.
The following is my command text where I am facing the problem:
command.CommandText = "SELECT * FROM InvoiceMaster WHERE InvoiceDate BETWEEN '"
+ date1.ToString() + "' AND '"
+ date2.ToString() + "' ORDER BY InvoiceNumber";
I need to find all results where the column InvoiceDate falls between the given dates date1 and date2. But the problem is that I am getting the results even though I choose other dates for example I get the same results for the same month and dates even though I choose a different year. There is something wrong with the command text and I also need to know what type of datatype should I choose in the db table. Please do let me know how I should be writing the select command.