简体   繁体   中英

query behaves differently on greater than equal and less than equal

I have one record in database which has date in it as March 31, 2015. If I use startdate:>="2015-03-01" AND startdate:<="2015-03-31" then I get no result but if I use startdate:>="2015-03-01" AND startdate:<"2015-04-01" then I get expected result. Isn't startdate:<="2015-03-31" and startdate:<"2015-04-01" are pretty much the same? Please advise.

That depends on the data type. If you are using for example SQL Server and you are using data type datetime , then you have both date and time. So 2015-03-31 means 2015-03-31 00:00:00 and 2015-04-01 means 2015-04-01 00:00:00 , so you get one missing day.

On the other hand these 2 conditions would be ALMOST identical:

startdate:<"2015-04-01"
startdate:<="2015-03-31 23:59:59"

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