开发者社区> 问答> 正文

android sqlite 获得当天有效的行

public Cursor getRowsBetweenDate(Date startAt, Date endAt) {

    String selection = KEY_START_AT + " >= time('now', 'localtime') AND " + KEY_END_AT + " <= time('now', 'localtime')";
    return sqLiteDatabase.query(TABLE_NAME, null, selection, null, null, null, null);
}

我想获取全天有效的行,不是只有现在有效的行。我想获取这几天有效的所有的行。时间是从 00:00 到23:59:59。
如何实现?

展开
收起
a123456678 2016-07-18 14:29:04 1724 0
1 条回答
写回答
取消 提交回答
  • String where = "strftime('%d.%m.%Y', date(?)) = strftime('%d.%m.%Y', 'now')";
    SimpleDateFormat dateFormat = "yyyy-MM-dd";
    String [] whereArgs = {dateFormat.format(KEY_END_AT) };
    cursor = sqLiteDatabase.query(TABLE_NAME, null, where , whereArgs, null,
                null, null);
    2019-07-17 19:57:52
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android内存泄漏自动化链路分析组件Probe 立即下载
微信SQLite数据库损坏恢复实践 立即下载