I want to get entries' date for a given month and year, for that I execute successfully in SQliteman the next query:
SELECT date FROM Entries WHERE strftime('%Y-%m',date) = '2013-04'
To use this query with QSqlQuery I use the following code
query.prepare("SELECT date FROM Entries WHERE strftime('%Y-%m',date) = ':year-:month'");
query.bindValue(":month", QString().sprintf("%02d", month));
query.bindValue(":year", QString::number(year));
But the error "Parameter count mismatch" is raised. That is for the quotes in :year and :month, but I have to use it or the query does not return any result.
How must the query be built if the quotes cannot be used?