Hi;
In my application I have a QDateEdit and a database.
I would like to send back from the database the users which date field are before the QDate in the QDateEdit.
I tried the next code, but seems like QDate is not compatible (cannot convert to long,long) with the query:
QDate testDate
= ui.
my_QDateEdit->date
();
QSqlQuery _date
((QString("SELECT id FROM users WHERE field_name_in_my_DB='%1' ") .arg(testDate), *myDatabase->GetDBPtr());
QDate testDate = ui.my_QDateEdit->date();
QSqlQuery _date((QString("SELECT id FROM users WHERE field_name_in_my_DB='%1' ")
.arg(testDate), *myDatabase->GetDBPtr());
To copy to clipboard, switch view to plain text mode
So I tried something that worked... but just when I need the same date, not before (lower), like I'd like:
//In my database the "date" field is "year-month-day"
QString strDate
= dyear
+ "-" + dmonth
+ "-" + dday;
QSqlQuery _date
((QString("SELECT id FROM users WHERE field_name_in_my_DB='%1' ") .arg(strDate), *myDatabase->GetDBPtr());
QString dday = QString::number(ui.my_QDateEdit->date().day());
QString dmonth = QString::number(ui.my_QDateEdit->date().month());
QString dyear = QString::number(ui.my_QDateEdits->date().year());
//In my database the "date" field is "year-month-day"
QString strDate = dyear + "-" + dmonth + "-" + dday;
QSqlQuery _date((QString("SELECT id FROM users WHERE field_name_in_my_DB='%1' ")
.arg(strDate), *myDatabase->GetDBPtr());
To copy to clipboard, switch view to plain text mode
I don't know if it helps, but I'm using PostgreSQL.
thanks!
Bookmarks