简体   繁体   English

SQLite的第二个日期大于第一个日期

[英]Sqlite second date is greater than first date

In my database I have patient records and in the table have column name Registered_Date in this yyyy-mm-dd format so when I execute query like 在我的数据库中,我有患者记录,并且表中的列名称为Registered_Date ,格式为yyyy-mm-dd因此当我执行类似

SELECT Patient_ID,First_Name,Middle_Name,Last_Name 
FROM Patient_Records 
WHERE Registered_Date BETWEEN '2019-01-25' AND '2018-10-01'

There is no result... 没有结果...

As you can see the first date is greater than the second date but there is no result, but if the first date is less than the second date it will result all the patient whose registered on the selected date. 如您所见,第一个日期大于第二个日期,但没有结果,但是,如果第一个日期小于第二个日期,则将导致所有在选定日期注册的患者。

Everything works as intended. 一切正常。

From the SQLite documentation : SQLite文档中

The BETWEEN operator is logically equivalent to a pair of comparisons. BETWEEN运算符在逻辑上等效于一对比较。 x BETWEEN y AND z is equivalent to x >= y AND x <=z x BETWEEN y AND z之间的x >= y AND x <=z等于x >= y AND x <=z

So if the first date is greater than the second (ie y > z ), the condition will always be evaluated as false, no matter what value ( x ) it is given. 因此,如果第一个日期大于第二个日期(即y > z ),则无论给出什么值( x ),该条件都将始终被评估为false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM