O
O
Oleg Seledets2018-08-14 20:20:06
SQL
Oleg Seledets, 2018-08-14 20:20:06

Why doesn't it understand the date type?

There is a change request in Qt like this:

setquery1->setQuery("UPDATE ships SET n_sudopot = '"+N_sp+"', data_prib_p_nazn = '"+data_prib.toString()+"', "
                               "dispetcher = '"+dispetcher+"' WHERE id="+indid+";");

The request itself is not executed.
data_prib_p_naznin MySQL it is of type DATE;
data_prib
tried to use in two types:
QDate data_vih = ui->dateEdit->date();               
QString data_vih = ui->dateEdit->date().toString();

If you remove the date from the request, then everything will work.
Which type would be used correctly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly, 2018-08-14
@oleja1ee7

According to the specification, the DATE type in SQL looks like this: yyyy-mm-dd. We go into the Qt documentation and see one of the signatures ( doc.qt.io/qt-5/qdate.html#toString-1 ):
QString QDate::toString(Qt::DateFormat format = Qt::TextDate) const
Ie . you need it like this: ui->dateEdit->date().toString(Qt::ISODate)

A
Andrey, 2018-08-14
@VladimirAndreev

What will return 2018-08-18 - that will do

R
res2001, 2018-08-14
@res2001

Try like this: '20180814'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question