0

I have a table with Date column with type DATE where values is looks like: '%d.%m.%Y'. How I can get rows for current month? I already tried:

SELECT *
FROM SampleTable
WHERE Date BETWEEN strftime('%d.%m.%Y', date('now','start of month')) AND
    strftime('%d.%m.%Y', date('now','start of month','+1 month','-1 day'))

But then I get all rows. I would be grateful for any help.

2jarrman
  • 1
  • 2
  • 2
    SQLite has no formal date type, and as a result dates are stored as plain text. This being the case, _it is critical_ that you store your text dates in an ISO format. This means a format like `%Y.%m.%d`, i.e. year, month, day. Your current date format will make _every_ query a real headache. I could give you a workaround, but that would just be feeding a beast. Fix your date data. – Tim Biegeleisen May 30 '18 at 06:18
  • You must change the date format to %Y.%m.%d or use [regex](https://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query). – Abhijeetk431 May 30 '18 at 06:31

0 Answers0