PL/SQL两个日期类型直接比较的问题。
在存储过程中有两个参数date1 Date,date2 Date
select * from table1 where start_date>=date1 and start_date<=date2;
start_date字段为Date类型,
发现一个奇怪的问题,在PLSQL Developer中测试这个存储过程,输入参数date1:2004-9-1,date2:2004-9-30,发现start_date为2004-9-30的记录没有查询到,改成
select * from table1 where to_char(start_date,'yyyy-mm-dd')>=to_char(date1,'yyyy-mm-dd') and to_char(start_date,'yyyy-mm-dd')<=to_char(date2,'yyyy-mm-dd')就没有问题,
虽然问题解决的,但是为什么会有第一种情况出现?
希望高手能解答!谢谢