I would like to know the past 7 days record. I want to write a query for that in where condition. I have very basic knowledge of sqlite. Please help me with this query.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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.