Undefined behaviour of QDate when converted to string
Solved
General and Desktop
-
I am trying to convert current system time to day month year format and store that in database table.
main.qml
QSqlQuery q; QString date = QDate::currentDate().toString("dddMMMyyyy"); q.exec("insert into users values(1, 'David', 'London', '"+date+"')"); qDebug() << "Error: " << q.lastError();
error:
QSqlError("22007", "QPSQL: Unable to create query", " ERROR: invalid input syntax for type date: \"SunFeb2020\"\nLINE 1: ...ers values(1, 'David', 'London', 'SunFeb202....\n ^\n(22007)")
-
Hi
If the database table type is of type date, it wont like a string formatted as
SunFeb2020 so you need to match the toString format to the one expceted by the DBMS.