PDA

View Full Version : Problem to insert 01.01.9999 to date column



mourad
10th October 2011, 09:29
Hello everyone,
I've an application which inserts records into a Firebird database. But when I want to insert the value "01.01.9999" to a Date column, this date is returned invalid by Qt and I won't retreive the record in my database.
Does anyone have an idea about this problem and can help me to resolve it.
Best regards

hoffen
10th October 2011, 10:04
maximumDate : QDate

This property holds the maximum date of the date time edit.

When setting this property the minimumDate is adjusted if necessary to ensure that the range remains valid. If the date is not a valid QDate object, this function does nothing.

By default, this property contains a date that refers to December 31, 7999.

Does this help?

mourad
10th October 2011, 11:42
Thank you for your quick response. I've searched how to change the range date but I've not found where.
Can you tell me how to do ? I'm usign Qt 4.3
Best regards.

hoffen
11th October 2011, 03:51
QDateTimeEdit :: void setMaximumDate ( const QDate & max )
This will do what you want

mourad
11th October 2011, 11:15
Thanks for your help but I've a console application. I can't use QDateTimeEdit.

israelins
11th October 2011, 13:53
Well, maybe you are doing something wrong.
Try to do something like this:

QSqlQuery qry;
QDateTime date = QDateTime::currentDateTime();

if (!qry.prepare("UPDATE user SET last_login = :last_login;")) {
qWarning() << qry.lastError();
}
qry.bindValue(":last_login", date);
if (!qry.exec()) {
qWarning() << qry.lastError();
}