Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. print simple Sqlite statement....
Forum Update on Monday, May 27th 2025

print simple Sqlite statement....

Scheduled Pinned Locked Moved Solved 3rd Party Software
2 Posts 1 Posters 757 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    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 ");
            query.exec();
            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')");
                datediff.exec();
    

    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?...

    1 Reply Last reply
    0
    • F Offline
      F Offline
      filipdns
      wrote on last edited by filipdns
      #2

      solved with add datediff.next(); :

      datediff.prepare("SELECT date FROM (SELECT(julianday('now') - julianday(?)) AS date)");
                  datediff.addBindValue(dateinsteng2);
                  datediff.exec();
                  datediff.next();
                  int tsn = datediff.value(0).toInt();
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved