dimanche 30 août 2015

SQLite extracting day from date issue

I have a DATE field in my database with format 'YYYY-MM-DD'. Now I want to extract only 'day' from that day i.e. 'DD'. My table name is 'date' and the column name where date is stored is 'lastDonated'. How do i do it... please look these codes for more details.

public String day() {
    String b = "";
    SQLiteDatabase db = getWritableDatabase();
    String query = "???(what to place in here?)";

    Cursor c = db.rawQuery(query, null);
    c.moveToFirst();

    b = c.getString(c.getColumnIndex("lastDonated"));

    c.moveToNext();

    return b;

}

Aucun commentaire:

Enregistrer un commentaire