[Solved] QDate Comparision issue
-
Hi friends,
I am using the expire concept using Qdate. @ QDate date = QDate::currentDate(); QString currentdate = date.toString("dd-MM-yyyy"); QString expiredate ="07-01-2014"; QDate expire1= QDate::fromString(expiredate,"dd-MM-yyyy"); QString s1 = expire1.toString(); if(s1<currentdate) { QMessageBox m1; m1.setText("Expired"); m1.exec(); } else { QMessageBox m1; m1.setText("Not Expired"); m1.exec(); }@
This is my code,,in here date comparison is not working,,every time messagebox shows "Not Expired",,,so please help this issue,,
Thanks
-
You are not comparing QDate objects... you are comparing QString objects. And they, as strings do, compare using alphabetical order comparison. You should use your QDate objects for comparison.
-
Hi sierdzio,,Now it's working,,Thanks
-
I am glad to hear that. I'll mark the thread as solved. Happy coding!