android sqlite3 sql语句之 根据时间段 查询

来源:互联网 发布:昆明知行素质教育中心 编辑:程序博客网 时间:2024/06/08 00:53

知识点:

1.时间格式

public static SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");

long nowMills=System.currentTimeMillis();

String endTime=DataTool.sdf3.format(nowMills);



1.询前10条记录,根据 字段 排序

select * from table where .... order by XX desc limit 0,10;

2.根据 时间日期 查询 :

注意时间格式必须是 2016-02-02

startTime="2016-02-02";

endTime="2016-03-04";

数据库中: birthdayDate 生日列名

String sql="select * from person where datetime(birthdayDate) between datetime('"
+startTime+"') and datetime('"+endTime+"')";

3.改-更新数据

String sql="update tableName set 列名 = '"
+ issue[7]+ "',lx = 'hf' where reportID = '"
+ issue[0]+ "' ";

4.增-新增数据


String sql="insert into qshf (reportID,reportTitle,reportContent,createTime,receiveContent,lx )values('"
+ issue[0]+ "','"
+ issue[1]+ "','" 
+ issue[2]+ "','"
+ newFormatTime+ "','"
+ issue[7]
+ "','hf' )";


注意:sql="select * from qshf where createTime between '2017-02-10' and '2017-02-13'";

最佳

2 0
原创粉丝点击