Qt World Summit: Submit your Presentation

print simple Sqlite statement....

  • Hello, I need your help for stupid thing...

    I'm using Sqlite for my qt application and it's easy to print value from table with:

    QSqlQuery query;
            query.prepare("SELECT rowid, data,  FROM table ");
            while (query.next()) {
                QString data= query.value(1).toString();

    that fine and easy...
    But I need to make date diff and the statement is:

    QSqlQuery datediff;
                datediff.prepare("SELECT julianday('now') - julianday('2007-02-02')");

    using db browser the query is working fine..

    but how can I print the result?....
    I try :

    double dateresult = datediff.value(1).toDouble();
    qDebug() << dateresult

    but it's not working... nothing is printed...

    Could you help me?...

  • solved with add datediff.next(); :

    datediff.prepare("SELECT date FROM (SELECT(julianday('now') - julianday(?)) AS date)");
                int tsn = datediff.value(0).toInt();

Log in to reply