首页 > 解决方案 > 在 Android Sqlite 中选择日期之间的查询

问题描述

桌子

以上是我的数据截图。如果目录介于开始日期和日期之间,我需要选择目录。我的查询是“ select catalog from hhItemDiscountOne where fromDate >= '20190305' and toDate <= '20190305'”。但即使日期在范围之间,我也没有得到值。

标签: androidsqlite

解决方案


这是我一见钟情时常犯的错误。您正在混合 from 和 to 条件。

没有 fromDate >= '20190305' 的条目,它们都是较小的 '20190301'。因此,如果您正在搜索日期在该范围内的值,则您的条件需要是

fromDate <= '20190305' and toDate >= '20190305'  

<=>=转动


推荐阅读