3
How do I filter the month on QSqlTableModel
?
I’m doing 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
model->select();
But without success. ThesetFilter
is only for WHERE
?
If you are using SQL Lite?
– user6026
@Fccdias Yes, sqlite
– Hy-brazil
By what I researched that’s right, with strftime within the setFilter, it does not issue errors? , Put more information like, the table of this survey, etc ...
– user6026
No mistake in the
lastError();
Dates are stored in the formatYYYY/MM/DD HH:MM:SS
.– Hy-brazil
How to know the SQL that this class generated ?
– user6026
Select * From tabela WHERE strftime('%m', campo_dataCadastro)='04'
I think this is the problemselect
.– Hy-brazil
So the right SQL ta, I myself have tested for example in my case was
SELECT * FROM Datas WHERE strftime('%m', Data) = '01'
, That’s why I find it strange– user6026