SQLite query time period of data problems solved!

Source: Internet
Author: User
Tags sqlite query

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?
    1. 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?
    1. 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?
  1. <pre class="sql" name="code" ><pre class="sql" name="code" ><pre class="  Java " name=" code "> SimpleDateFormat sdf=new simpledateformat (" Yyyy-mm-dd ");
  2. Cur_calender.  set (year, month, day );
  3. Switch (sel_date_type) {
  4. Case 1://start time
  5. if (search_date_begin!=null) {
  6. Date_start =sdf.format (Cur_calender.gettime ());
  7. Search_date_begin.settext (Date_start);
  8. }
  9. Break
  10. Case 2://End time
  11. if (search_date_end!=null) {
  12. Date_end = Sdf.format (Cur_calender.gettime ());
  13. Search_date_end.settext (Date_end);
  14. }
  15. Break
  16. Default:
  17. Break
  18. }
  19. } </pre>
  20. <p><br>
  21. It's OK now! <br>
  22. </p>
  23. <p> </p>
  24. <pre></pre>
  25. <pre></pre>
  26. <pre></pre>
  27. <pre></pre>
  28. <pre></pre>
  29. </pre></pre>,

Original address: http://blog.csdn.net/zz_mm/article/details/7453925

SQLite query time period of data problems solved!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.