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

知识点:

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'";

最佳

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值