Hello,

I am working with the project where I am using 2 QDateEdit and a button.

I need to fetch data between the specified dates, first date is selected from QDateEdit and the second date is from other QdateEdit

One QDateEdit is to select fromdate and the other is to select todate.

I executed the query in Sqlite3 Managment studio,it works but when I send query through Qt problem arrives.

Code:

Qt Code:
  1. QString FromcalenderDate,TocalenderDate;
  2. FromcalenderDate=ui->dateEdit->date().toString("yyyy-MM-dd");
  3. qDebug() << FromcalenderDate;
  4. TocalenderDate=ui->dateEdit_2->date().toString("yyyy-MM-dd");
  5. qDebug() << TocalenderDate;
  6.  
  7. if(!db.isOpen())
  8. {
  9. qDebug()<<"Failed to database open.";return;
  10. }
  11.  
  12. QSqlQuery query;
  13.  
  14. if(query.exec("SELECT * FROM employees WHERE BirthDate>='"+FromcalenderDate +"' AND BirthDate<='"+TocalenderDate +"' "))
  15.  
  16.  
  17. // if(query.exec("SELECT * FROM employees WHERE BirthDate BETWEEN ('"+FromcalenderDate +"' '"+TocalenderDate +"')"))
To copy to clipboard, switch view to plain text mode 


There is no problem with the database connection as I am getting data for below queries:

Qt Code:
  1. if(query.exec("SELECT * FROM employees WHERE BirthDate ='"+FromcalenderDate +"'"))
  2.  
  3. if(query.exec("SELECT * FROM employees"))
To copy to clipboard, switch view to plain text mode 

I think the problem is I am leaving some some special character or Is there any format to send date to database


Any kind of help is appriciable,

Thanks and Regards,
Lokesh