[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();
        QMessageBox m1;
        QMessageBox m1;
        m1.setText("Not Expired");

    This is my code,,in here date comparison is not working,,every time messagebox shows "Not Expired",,,so please help this issue,,


  • Moderators

    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

  • Moderators

    I am glad to hear that. I'll mark the thread as solved. Happy coding!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.