Note that there are some explanatory texts on larger screens.

plurals
  1. PORun Query with Data condition Sqlite
    primarykey
    data
    text
    <p>i have an other problem <strong><em>DBAdapter.java</em></strong>:</p> <pre><code>public Cursor getTotalFlightTime_Custom() throws SQLException{ return db.rawQuery("SELECT time(sum(strftime('%s', Total_Flight_Time) - strftime('%s','00:00:00')),'unixepoch') FROM Flights WHERE Date BETWEEN '01/01/2012' AND '01/02/2012'",null); } </code></pre> <p><em><strong>MainActivity.java</em></strong>:</p> <pre><code>private void CustomReport(){ DBHelper.open(); TextView txt = (TextView)findViewById(R.id.lblReportTotalFlightTimeAUTO); Cursor cursor = DBHelper.getTotalFlightTime_Custom(); cursor.moveToFirst(); String[] names = cursor.getColumnNames(); String AUTO = cursor.getString(cursor.getColumnIndex(names[0])); if(AUTO == "") txt.setText("00:00:00"); else txt.setText(AUTO); } </code></pre> <p>The problem is that the query is not working. I wan the query to return the <strong>SUM</strong> from column <strong>Total_Flight_Time</strong>, table <strong>Flights</strong> in HH:MM:SS format for lines with <strong>Date</strong> column between <em>01/01/2012</em> and <em>01/02/2012</em> (DD/MM/YYYY). I had try YYYY-MM-DD format too but the program just crashing with no message.</p> <p>I think i know where the problem is but i'm not sure:</p> <pre><code>WHERE Date BETWEEN '01/01/2012' AND '01/02/2012' </code></pre> <p>BUT i don't know how to fix it. The other part of the Query should be correct because i used it for the same column but the entire table and it works as i expected.</p> <p><em><strong>EIDT:</em></strong> Data column is stored as <strong>INTEGER</strong></p> <p>Can you help me? Thanks in advice:D</p> <p><em><strong>Comment Code:</em></strong></p> <pre><code>String dateStringfrom = "01/01/2012"; String dateStringto = "01/02/2012"; SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); Date convertedDatefrom = new Date(); Date convertedDateto = new Date(); try { convertedDatefrom = dateFormat.parse(dateStringfrom); convertedDateto = dateFormat.parse(dateStringto); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(convertedDatefrom); System.out.println(convertedDateto); Log.d("Converted From","result: " + convertedDatefrom); Log.d("Converted To","result: " + convertedDateto); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload