开发者社区> 问答> 正文

如何根据当前日期过滤记录?

我正在实现一种功能,我以String形式存储日期并通过使用LocalDate函数以字符串形式获取当前日期,因此我想比较两个日期,我只想获取当前日期记录。

找不到错误,但记录无法提取。

public ArrayList<Followup_Model> followup_reminder (ArrayList<Followup_Model> followup_Model_list) { if (followup_Model_list == null) { followup_Model_list = new ArrayList<>(); } SQLiteDatabase sqLiteDatabase = this.getReadableDatabase(); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); LocalDate localDate = LocalDate.now(); String Today = dtf.format(localDate); Cursor followup_output = sqLiteDatabase.rawQuery("SELECT * FROM " + Table_Name_Followup + " WHERE CREATEDBY = '1' AND CHECKED = '1' AND STARTDATE = " + Today + " ORDER BY REMINDER ASC",null);

展开
收起
小六码奴 2019-10-09 19:07:49 951 0
2 条回答
写回答
取消 提交回答
  • 精于基础,广于工具,熟于业务。

    String Today = dtf.format(localDate);建议把这一句打印出来看一下,是否很您数据库中存储的一致。

    2019-10-10 16:20:29
    赞同 展开评论 打赏
  • 只需复制并粘贴。

    public ArrayList<Followup_Model> followup_reminder (ArrayList<Followup_Model> followup_Model_list) { if (followup_Model_list == null) { followup_Model_list = new ArrayList<>(); } SQLiteDatabase sqLiteDatabase = this.getReadableDatabase(); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd"); LocalDate localDate = LocalDate.now(); String Today = dtf.format(localDate); Cursor followup_output = sqLiteDatabase.rawQuery("SELECT * FROM " + Table_Name_Followup + " WHERE CREATEDBY = '1' AND CHECKED = '1' AND STARTDATE = '" + Today + "'" + " ORDER BY REMINDER ASC",null);

    2019-10-09 19:08:06
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载