I have a table containing a date field. I saved the date field when creating the table as Integer. The user choose the date using a date picker and the date is stored in the format: dd/mm/yy. I want to return the rows in the table where dates in the field date > current date I tried the following query:
public Cursor getUpcomAp ( ) {
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery (" select * from " + TABLE_NAME2 + "where strftime('%d.%m.%Y', date) > now.strftime('%d.%m.%Y')" , null);
return res;
}
The application crashes when I click on the button that execute this query. Here is the logcat output:
01-02 12:28:48.252: E/SQLiteLog(1316): (1) near "(": syntax error
01-02 12:28:48.262: D/AndroidRuntime(1316): Shutting down VM
01-02 12:28:48.262: W/dalvikvm(1316): threadid=1: thread exiting with uncaught exception (group=0xb1ad4ba8)
01-02 12:28:48.282: E/AndroidRuntime(1316): FATAL EXCEPTION: main
01-02 12:28:48.282: E/AndroidRuntime(1316): Process: com.example.appointapp, PID: 1316
01-02 12:28:48.282: E/AndroidRuntime(1316): android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling: select * from appointments_tablewhere strftime('%d.%m.%Y', date) > now.strftime('%d.%m.%Y')
01-02 12:28:48.282: E/AndroidRuntime(1316): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
Please help
Aucun commentaire:
Enregistrer un commentaire