Solve the data issue during SQLite query period!

Source: Internet
Author: User
Tags sqlite query

Recently, we are engaged in local SQLite queries. We need to query data within a certain period of time. In SQL, we all know that:

select * from tblName where rDate Between '2008-6-10' and  '2008-6-12'

There is no problem in this way, but in SQLite we cannot get the result of writing this way. After trying it many times, we finally found that the rule is as follows:

select * from tblName where rDate Between '2008-06-10' and  '2008-06-12'

This is OK, so the rule we get is that our time must be formatted, So we introduced the following code to format the time:

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 ;}}

Now OK!

 

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.