Reputation: 27
I use this query to create a TABLE of transaction in my Database :
String CREATE_TRANSITION_TABLE1 = "CREATE TABLE "
+ TABLE_TRANSITION_TWO + "(" + KEY_TRASITIONID
+ " INTEGER PRIMARY KEY," + KEY_AMOUNT_CREDIT + " DOUBLE,"
+ KEY_AMOUNT_DEBIT + " DOUBLE," + KEY_PURPOSE + " TEXT,"
+ KEY_PURPOSE1 + " TEXT," + KEY_PURPOSE2 + " TEXT," + KEY_DATE
+ " DATE," + KEY_BALANCE + " DOUBLE" + ")";
And this Query to Fetch all transaction from the Table :
String selectQuery = "SELECT * FROM " + TABLE_TRANSITION_ONE;
Now I would like to filter the result within a particular range of Date . Like :
StartDate : 2/1/2015
EndDate : 6/1/2015
I needed Query to do the Operation .. Need Immediate assistance .
Upvotes: 1
Views: 152
Reputation: 2467
You can try this.
SELECT * From TABLE_NAME WHERE date_column BETWEEN '"+StartDate+"' AND '"+EndDate+"';
Full Query :
"SELECT * FROM " + TABLE_TRANSITION_ONE + " where " + KEY_DATE + " BETWEEN '2015-02-05' AND '2015-02-15';
Here, StartDate and EndDate are string variable.
But for this operation your date should be in YYYY-MM-DD format.
Upvotes: 1