简体   繁体   中英

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

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 :

The BETWEEN operator is logically equivalent to a pair of comparisons. x BETWEEN y AND z is equivalent to 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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