Jayanta Mukherjee

Jayanta Mukherjee

  • 1.5k
  • 120
  • 38.7k

Unable to filter between two dates in dd-mm-yyyy format in SQLite c#

Mar 22 2022 3:01 PM

I'm using SQLite Core .Net framework for database in my c# WPF app and I've added a table in the database.db with multiple columns. One of the columns payDt contains date in dd-mm-yyyy format but since there are no date datatypes in SQLite I've made the datatype for column payDt as text.

Now when I'm trying to filter the table data by date and view it in a datagrid it is not showing anything. I've gone through multiple posts on the internet and have tried the below different approaches but to no avail...

"SELECT * FROM myTable WHERE payDt BETWEEN strftime('%d-%m-%Y','28-02-2022') AND strftime('%d-%m-%Y','25-03-2022')"

"SELECT * FROM myTable WHERE payDt BETWEEN strftime('%Y-%m-%d','2022-02-28') AND strftime('%Y-%m-%d','2022-03-25')"

"SELECT * FROM myTable WHERE payDt BETWEEN '2022-02-28' AND '2022-03-25'"

"SELECT * FROM myTable WHERE payDt BETWEEN '28-02-2022' AND '25-03-2022'"

Please help !!


Answers (2)