2014-04-16 60 views
0

我想查詢過去30分鐘內的記錄。如何查詢顯示時間不超過30分鐘的記錄

     String CREATE_FOJ_TABLE = "CREATE TABLE " + TABLE_FOJ 
      + "(" + KEY_FOJID + " INTEGER PRIMARY KEY," + KEY_FOJPICKUPPOINT 
      + " TEXT," + KEY_FOJDESTINATION + " TEXT," + KEY_FOJPICKUPTIME 
      + KEY_FOJFARES + " TEXT," + 
          KEY_FOJSPECIAL 
      + " TEXT," +KEY_FOJVIA + 
         " TEXT," + KEY_FOJMILAGE 
      + " TEXT" + ")"; 



    ////////  this is my query ////////////// 

        String selectQuery = "SELECT * FROM " + TABLE_FOJ +" ORDER BY "+ 
     KEY_FOJPICKUPTIME; 
+0

如何讓時間beofre 30分鐘??????? – user3472001

+0

什麼時間格式你在哪列? – Saqib

+0

即時通訊使用文本日期時間KEY_FOJPICKUPPOINT \t \t \t \t +「TEXT」 – user3472001

回答

0

試試這個: 工程爲MySQL

SELECT * FROM TABLE_NAME WHERE your_timestamp_columnname BETWEEN timestamp(DATE_SUB(NOW(), INTERVAL 30 MINUTE)) AND timestamp(NOW()) 
+0

是什麼日期,分時段等,請根據我的tablle爲sqllite – user3472001

+0

DATE_SUB()告訴的是,從減去已知的時間間隔的功能。日期。 – Vamshi

+0

你有沒有date_sub的錯誤? – Vamshi

相關問題