I am trying to perform an insertion into a SQLite database from a c++/QT application.
One of the columns of the table where I want to insert the data is a datetime (yyyy-mm-dd hh:mm:ss).
I have try to use this code:
...
query.prepare("INSERT INTO table (table_date_time, ...) "
" VALUES (?, ...);");
query.bindValue(0, "datetime('2004-12-11 13:00:00', '+1 day')");
...
but it inserts the text “datetime(‘2004-12-11 13:00:00’, ‘+1 day’)” instead the value 2004-12-12 13:00:00.
If I try
...
query.prepare("INSERT INTO table (table_date_time, ...) "
" VALUES (datetime(?), ...);");
query.bindValue(0, "2004-12-11 13:00:00, +1 day");
...
or
...
query.prepare("INSERT INTO table (table_date_time, ...) "
" VALUES (datetime(?), ...);");
query.bindValue(0, "'2004-12-11 13:00:00',' +1 day'");
...
the datetime field does not get filled.
What is the correct way to use datetime functions allong parameters?
Thanks in advance.
A bound value only replaces one parameter, the 2 parameters to the
datetimefunction have to be sent separately: