在postgresql(windows版本9.2.4)中比较日期时,我一直面临着一个奇怪的场景。
我有一个列在我的表说update_date类型的时间戳没有时区。客户端可以在该字段中只搜索日期(例如: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
我的问题是我如何能使第一个查询可能得到结果,我的意思是为什么第三个查询工作,而不是第一个?