QDateTime fromString () does not work
Solved
General and Desktop
-
I am trying to get a DATETIME from an sql server and the formatting is being yyyy-MM-dd hh:mm:ss but an invalid date is returned.
This is the value returned by query 2019-06-14T08:43:48.000, also inserts a timestamp manually as shown below but the value remains invalid
QDateTime Vendas::feitaEm() const { QDateTime dt; dt.fromString("2019-06-16 09:45:05", "yyyy-MM-dd hh:mm:ss"); qDebug() << dt.date(); return QDateTime::fromString(data.value(7), "yyyy-MM-dd hh:mm:ss"); }
-
QDateTime dt; dt.fromString("2019-06-16 09:45:05", "yyyy-MM-dd hh:mm:ss"); qDebug() << dt.date();
Try:
QDateTime dt = QDateTime::fromString("2019-06-16 09:45:05", "yyyy-MM-dd hh:mm:ss"); qDebug() << dt.date();
-
@Samuel-Ives said in QDateTime fromString () does not work:
but it's strange that the result of the query is with a 'T' in the timestamp while the server is not present
Do you mean you're not connected to the SQL server? In that case you can't execute queries, so I'm wondering what exactly you're doing.