I am having below table on my android sqlite database.
My Date filed is TEXT;
ID Name Date
1 ABY 2014-12-01
2 RUBY 2015-01-10
3 AMY 2015-01-15
4 ROBEN 2014-10-25
I need to sort the result like in mysql
select * from Table where YEAR(DATE)='2015';
How can I get the above result in Andorid sqlite database?
I think you want to use the LIKE operand
SELECT * FROM table WHERE Date LIKE '2015%'
http://www.tutorialspoint.com/sqlite/sqlite_like_clause.htm
Edit for query:
String selectQuery = "SELECT id, name FROM table WHERE date like \'" + "2015" + "\'";
Cursor c = db.rawQuery(selectQuery, new String[] { fileNameOfDb });
if (c.moveToFirst()) {
name = c.getString(c.getColumnIndex("name"));
}
c.close();