select * from tb where trunc(datecol)=to_date('2004-06-22','yyyy-mm-dd');

解决方案 »

  1.   

    select * from 表名
     where 时间字段名=to_date('2004-06-22','yyyy-mm-dd');
      

  2.   

    select * from table 
    where Col >= to_date('2004-06-22','yyyy-mm-dd')
    and Col <= to_date('2004-06-22','yyyy-mm-dd')+1
      

  3.   

    好像不对,因为他定义的字段Col的格式是:2004-6-22 15:16:17,这是一个字符串时间。
    用 select * from table 
    where Col >= to_date('2004-06-22','yyyy-mm-dd')
    and Col <= to_date('2004-06-22','yyyy-mm-dd')+1一个是时间类型to_date(),一个是字符串类型,怎么比较?
      

  4.   

    如果你的时间字段定义的是VARCHAR 类型,例如: MyTime VARCHAR2(20);那么可以这样做:  select * from YourTable
      where YourCol like '2004-06-22%';如果是时间类型的:
      select * from YourTable
      where YourCol > to_date('2004-06-22','yyyy-mm-dd');