select * from A
where finish_time>= date'2013-1-1'
and finish_time<= date '2013-1-31'是不是少2013-1-31这天的数据?
因为finish_time 是date格式,date '2013-1-31'应该是这天的2013:1:13:00:00时间。
第三行不是不要改成and finish_time< date '2013-2-1'。
求高手。

解决方案 »

  1.   

    因为finish_time 是date格式,date '2013-1-31'应该是这天的2013:1:13:00:00时间。
    第三行不是不要改成and finish_time< date '2013-2-1'。是这样的,
    类似的写法还有  
    and finish_time<= to_date('2013-1-31 23:59:59','yyyy-mm-dd hh24:mi:ss')and trunc(finish_time)<= date '2013-1-31'--不提倡
      

  2.   

    如楼上说的,你直接把条件改成 and finish_time<= to_date('2013-1-31 23:59:59','yyyy-mm-dd hh24:mi:ss') 就包括31的了
      

  3.   

    create table testdate
    (name varchar2(10),
    dt  date)
    insert into testdate(name,dt)
    values('test',to_date('2013-2-22 15:00:00','yyyy-mm-dd hh24:mi:ss'))
    select * from testdate where dt<=date'2013-2-22'
    以上
    与其花时间纠结,不如用2分钟自己测试下。