table t 
字段cdate的类型是DATE ,存储的数据格式是 yyyy-mm-dd
我这样查询没问题
select * from t where t.cdate = to_date('日期','yyyy-mm-dd') 日期传递数据的格式是yyyy-mm-dd现在存储的数据格式变了 yyyy-mm-dd hh:mm:ss,就查不出来了.
请问下怎么改最方便,因为sql语句改动的地方会比较多

解决方案 »

  1.   

    select * from t where t.cdate = to_date('日期','yyyy-mm-dd hh:mm:ss')那你查询的时候,也要改下格式
      

  2.   

    select * from t where t.cdate = trunc(to_date('日期','yyyy-mm-dd hh:mm:ss'))
      

  3.   

    date类型的字段在数据库中查询出来的结果是yyyy-mm-dd hh:mm:ss这种形式显示,如果按天查数据那不是这样to_date('日期','yyyy-mm-dd')?
      

  4.   

    select * from t where t.cdate between to_date('日期','yyyy-mm-dd') and to_date('日期','yyyy-mm-dd')+1-1/24/60/60
      

  5.   

    t.cdate =trunc(to_date('日期','yyyy-mm-dd hh:mm:ss'))
      

  6.   


    select * from t where t.cdate = trunc(to_date('日期','yyyy-mm-dd hh:mm:ss'));
      

  7.   

    trunc(to_date('日期','yyyy-mm-dd hh:mm:ss'));
      

  8.   

    谢谢各位。
    如果我这么写呢
    select * from t where  to_char(t.cdate,'YYYY-MM-DD') ='日期'
    执行效率上会有什么不同或会造成哪些未知的问题?
      

  9.   

    谢谢大家,麻烦各位了.select * from t where trunc(t.cdate) = to_date('日期','yyyy-mm-dd');
    select * from t where to_char(t.cdate,'YYYY-MM-DD') ='日期'
    这2个都行