java - SQlite WHERE statement not working? -


i making app stores books titles, date added , date book needs returned by. below, show where statement gets books due returned between today's date , 2 days hence, returned listview. not work, however, , i'm not sure i'm going wrong:

    public cursor fetchalldue() {      //get todays date     calendar cal=calendar.getinstance();     int currentday=cal.get(calendar.day_of_month);      //add days on todays date     cal.set(calendar.day_of_month, currentday+2);     cal.gettime(); //result      //format string     string formatteddate = new simpledateformat("dd-mm-yyyy hh:mm").format(cal.gettime());     //get todays date     calendar cal1=calendar.getinstance();     int currentday1=cal1.get(calendar.day_of_month);      //atodays date     cal1.set(calendar.day_of_month, currentday1);     cal1.gettime(); //result      //format string     string formatteddate1 = new simpledateformat("dd-mm-yyyy hh:mm").format(cal1.gettime());       //body = date added, needs changed     return mdb.query(database_table, new string[] { key_rowid, key_title,             key_body, key_extra, key_due }, key_due + " between 'formatteddate1' , 'formatteddate2'", null, null, null, null); } 

this code when date input "due date":

                //convert string int.             int mynum = integer.parseint(editbox3.gettext().tostring());              //get todays date             calendar cal=calendar.getinstance();             int currentday=cal.get(calendar.day_of_month);              //add days on todays date             cal.set(calendar.day_of_month, currentday+mynum);             cal.gettime(); //result              //formate string             string formatteddate = new simpledateformat("dd-mm-yyyy hh:mm").format(cal.gettime());               bundle.putstring(notesdbadapter.key_due,formatteddate                     .tostring()); 

the dates strings. can help?

pretty work buddy.

essentially mix of 2 other answers.

     string[] params = new string[] { string.valueof(formatteddate1), string.valueof(formatteddate2) };       return mdb.rawquery("select * " + database_table + " duedate between ? , ?", params); 

let me know if helps.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -