i would need to know the past 7 days record. i want to wrote a query for that in where condition. i have very basic knowledge in sqlite. Please help me for this query.
sqlite doesn't keep track of when your table rows were added. If you need this behavior you should add a timestamp column and set the current time in it when you insert a new row.
You need to store the date in one of the columns in your DB. In my app I convert the NSDate (iPhone obviously) to a double for storing in the DB using timeIntervalSinceReferenceDate. Given that I can query for a date range.
I wrote functions that calculate the NSDate for midnight X days in the past/future, which I use to determine the startDate and endDate of queries. Here is an excerpt from the code that will give you some idea:
char selectQuery[MAX_STR];
sprintf(selectQuery, "SELECT DateTime FROM Journal WHERE DateTime >= %f AND DateTime < %f;",
[startDate timeIntervalSinceReferenceDate],
[endDate timeIntervalSinceReferenceDate]);
I didn't want to convert NSDate to date time strings because I don't trust the conversions back and forth with all the various timezones and different locale's ways of formatting dates.