Recently engaged in SQLite local query, the requirement is to query the data for a time period, in SQL we know that:
[SQL]View Plaincopyprint?
- SELECT * from tblname where rdate between ' 2008-6-10 ' and ' 2008-6-12 ' /c3>
SELECT * from Tblname where rdate between ' 2008-6-10 ' and ' 2008-6-12 '
This is not a problem, but in SQLite we do not have the result of writing, tried many times finally found in the law, we wrote as follows:
[SQL]View Plaincopyprint?
- SELECT * from tblname where rdate between ' 2008-06-10 ' and ' 2008-06-12 '
SELECT * from Tblname where rdate between ' 2008-06-10 ' and ' 2008-06-12 '
This is OK, so the rule is that our time must be formatted, so we introduced the following code to format the time:
[SQL]View Plaincopyprint?
- <pre class="sql" name="code" ><pre class="sql" name="code" ><pre class=" Java " name=" code "> SimpleDateFormat sdf=new simpledateformat (" Yyyy-mm-dd ");
- Cur_calender. set (year, month, day );
- Switch (sel_date_type) {
- Case 1://start time
- if (search_date_begin!=null) {
- Date_start =sdf.format (Cur_calender.gettime ());
- Search_date_begin.settext (Date_start);
- }
- Break
- Case 2://End time
- if (search_date_end!=null) {
- Date_end = Sdf.format (Cur_calender.gettime ());
- Search_date_end.settext (Date_end);
- }
- Break
- Default:
- Break
- }
- } </pre>
- <p><br>
- It's OK now! <br>
- </p>
- <p> </p>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- </pre></pre>,
Original address: http://blog.csdn.net/zz_mm/article/details/7453925
SQLite query time period of data problems solved!