如何使用Sqlite数据库在java中的两个日期之间进行搜索

时间:2016-01-27 19:27:58

标签: java jcalendar

我正在使用jCalender输入日期

String from_date = ((JTextField) txt_bilty_date_start.getDateEditor().getUiComponent()).getText();
String to_date = ((JTextField) txt_bilty_date_end.getDateEditor().getUiComponent()).getText();
String sql = " "; //what query I need to use

enter image description here

1 个答案:

答案 0 :(得分:3)

我不是java pro,但SQL语句可能就像这样

select * from POSTS where Id = 1
       and Date between '2011/02/25' and '2011/02/27'

或可以使用

select * from POSTS where Id = 1
       and Date >= '2011/02/25' and Date <= '2011/02/27'