c++ – Filter month in QSqlTableModel


How do I filter the month in QSqlTableModel ?

I'm doing it like this:

model = new QSqlTableModel(this);
model->setTable("tabela"); // db sqlite
model->setFilter("strftime('%m', campo_dataCadastro)='04'");//db YYYY/MM/DD HH:MM:SS

But without success. Is setFilter only for WHERE ?


Fixed, The problem was the date format stored in sqlite . Convert date to YYYY-MM-DD HH:MM:SS and the filter worked.

Scroll to Top