让我们说我有一张桌子上有人的名字和他们的生日(日期和时间)。 我希望能够使用以下SQL for SQLite找到今天的人们的生日(日期和时间)。
SELECT * FROM Btable WHERE Bday = date('yyyy-MM-dd')但是,它始终使用nil数据集返回。 我还需要包括时间吗?
我的SQL语句究竟出了什么问题? 如果是这样,查询今天日期的正确SQL语句是什么。
更新:
这是我使用BETWEEN逻辑的实际SQL语句:
SELECT * FROM Alarms WHERE ALARMSTATE IN (0,1,2) AND ALARMPRIORITY IN (0,1,2,3,4) AND ALARMGROUP IN (0,1,2,3,4,5,6,7) AND ALARMTIME BETWEEN date(2012-08-02) AND date(2012-08-3) ORDER BY ALARMTIME DESCLets just say I have a table with people's name and their birthday (date and time). I want to be able to find people's birthday (date and time) for today using the following SQL for SQLite.
SELECT * FROM Btable WHERE Bday = date('yyyy-MM-dd')However, it is always returning with nil dataset. Do I need to also include the time as well?
What is exactly wrong with my SQL statement? If so, what is the correct SQL statement for querying for todays date.
UPDATE:
Here is my actual SQL statement using BETWEEN logic:
SELECT * FROM Alarms WHERE ALARMSTATE IN (0,1,2) AND ALARMPRIORITY IN (0,1,2,3,4) AND ALARMGROUP IN (0,1,2,3,4,5,6,7) AND ALARMTIME BETWEEN date(2012-08-02) AND date(2012-08-3) ORDER BY ALARMTIME DESC最满意答案
我没有旋转的实例,但这应该工作。
SELECT * FROM Btable WHERE Bday >= julianday(date('now')));这应该像这样返回一个String:
2012-08-02 00:00:00查询错误的地方在于它可能缺少毫秒或其他一些总是评估为false的精度。
Here is my answer.
Since my column ALARMTIME is TEXT, I am able to query my table with the following SQL statement and retrieve dataset I am looking for.
SELECT * FROM Alarms WHERE ALARMSTATE IN (0,1,2) AND ALARMPRIORITY IN (0,1,2,3,4) AND ALARMGROUP IN (0,1,2,3,4,5,6,7) AND ALARMTIME LIKE "2012/08/01%" ORDER BY ALARMTIME DESCI simply can't convert my ALARMTIME text into datetime type.
更多推荐
发布评论