在postgresql(Windows版本9.2.4)中比较日期时,我遇到了一个奇怪的情况.我的表中有一列说update_date,类型为'timestamp without timezone'.客户可以仅使用日期(即:2013-05-03)或日期与时间(即:2013-05-03 12:20:00)搜索此字段.此列的值为当前所有行的时间戳,并且具有相同的日期部分(2013-05-03)但时间部分不同.
当我在这个专栏中进行比较时,我得到了不同的结果.如下:
select * from table where update_date >= '2013-05-03' AND update_date <= '2013-05-03' -> No results
select * from table where update_date >= '2013-05-03' AND update_date < '2013-05-03' -> No results
select * from table where update_date >= '2013-05-03' AND update_date <= '2013-05-04' -> results found
select * from table where update_date >= '2013-05-03' -> results found
Run Code Online (Sandbox Code Playgroud)
我的问题是如何才能使第一个查询获得结果,我的意思是为什么第三个查询工作但不是第一个?
任何人都可以帮我吗?提前致谢.