Results 1 to 4 of 4

Thread: Export the data in between a specified time range from Sql DB to Excel

  1. #1
    Join Date
    May 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default Export the data in between a specified time range from Sql DB to Excel

    Hi friends i have a small problem, I have a sqlite db in which there is a time range say from 17:30:35 to 17:45:55 now i have used two Q3TimeEdit to select the starting and The Ending Time and to export the selected time range values to excel.
    Qt Code:
    1. void testexport::on_pushButton_4_clicked()
    2. {
    3. QTime time1 = Q3TimeEdit->time();
    4. QTime time2 = Q3TimeEdit_2->time();
    5. time_range.clear();
    6. QStringList time_fields;
    7. QSqlQuery time_query_header("select * from Plotting_data1 where 1=0"); //don't actually select anything but get a reference to the record set
    8. QSqlRecord time_header_count = time_query_header.record();
    9. QSqlQuery range("SELECT * FROM Plotting_data1 where Time>= ''time1" and Time<="time2"); // I get an error i tried so many things but i don get the desired o/p
    To copy to clipboard, switch view to plain text mode 

    In .Net ("SELECT * FROM Plotting_data1 where Time>= ' '' +time1+ " ' and Time<= ' '' +time2+ " ' "); by doing this i got the values in between the Start time and end time to excel. What do i need to do for Qt

    When i pass the time directly i get the values between the intervals which i have specified,But when i try to pass it from the Q3TimeEdit i don't get.
    QSqlQuery range("SELECT * FROM Plotting_data1 where Time>= '17:30:35' and Time<='17:35:55'"); // How to pass the values i have given in the Q3TimeEdit i have used.

  2. #2
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Export the data in between a specified time range from Sql DB to Excel

    read here about bindValue function
    http://doc.trolltech.com/4.4/qsqlquery.html

  3. #3
    Join Date
    May 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: Export the data in between a specified time range from Sql DB to Excel

    Hi,

    Thanks for the link. It din help me. But i some how solved my problem .!!!


    Thankx
    Last edited by maveric; 12th June 2008 at 11:25.

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Export the data in between a specified time range from Sql DB to Excel

    Qt Code:
    1. SELECT * FROM Plotting_data1 where Time>= '17:30:35' and Time<='17:35:55
    To copy to clipboard, switch view to plain text mode 
    and order by Time???

    I think only oracle cam make this.....


    Use the UnixTime is more efficient!
    all os can handle ....

    on mysql
    select a,FROM_UNIXTIME(timebounce,'%d.%c.%Y'),....
    http://dev.mysql.com/doc/refman/5.0/...functions.html

    or

    Qt Code:
    1. QDateTime times;
    2. times.setTime_t(resultunixtime);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. QDateTime timer1( QDateTime::currentDateTime() );
    2. const uint now = timer1.toTime_t();
    To copy to clipboard, switch view to plain text mode 

    1213268102 = Date: Thu, 12 Jun 2008 12:55:02
    1213268103 = Date: Thu, 12 Jun 2008 12:55:03
    0 = 1.1.1970

    on sql order by time desc the new come first && old last...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.