select * from tableN where to_date(dateN,'yyyy-mm-dd')=to_date('2004-01-01','yyyy-mm-dd')
这句就提示日期在转换之前就结束了

解决方案 »

  1.   

    to_char()只有2个版本,一个用于日期型转换,一个用于数值型转换你本来就是字符型的 还怎么转啊?既然已经是字符型了 要么转成日期 要么干脆就是进行字符比较
      

  2.   

    select * from tableN where dateN='2004-01-01'
    如果直接比较又没有数据出来了。
      

  3.   

    你字符的日期格式是 :2004-01-12 12:24:23 怎么可以用 yyyy-mm-dd格式去转换啊
      

  4.   

    select * from tableN where dateN='2004-01-01'
    如果直接比较又没有数据出来了。当然没数据啦 
    '2004-01-01' 和 "2004-01-12 12:24:23"  会相等么????
      

  5.   

    如果你能保证 数据都是这个格式:2004-01-12 12:24:23 
    那么前10位就是年月日,直接比较不就可以了?
    select * from tableN where substr(dateN,1,10)='2004-01-01'
      

  6.   

    select * from tableN where substr(dateN,1,10)='2004-01-01'支持这句
      

  7.   

    select * from tableN where to_char(dateN,'yyyy-mm-dd')='2004-01-01'
    这句你的dateN本来就是字符型的,再to_char当然不可以了
    select * from tableN where to_date(dateN,'yyyy-mm-dd')=to_date('2004-01-01','yyyy-mm-dd')
    这句你的日期是这样的2004-01-12 12:24:23。
    '2004-01-01' 和 "2004-01-12 12:24:23"当然不可能相等了
    既然你的日期格式是字符型的,那就直接截取字符串就可以了
    select * from tableN where substr(dateN,1,10)='2004-01-01'这样解释你应该都明白了吧??
      

  8.   

    明白得很彻底了。
    其实我开始以为to_char 这些函数的功能可以随后面的表达式而改变的。现在看来是不行的了。
      

  9.   

    select * from tableN where substr(dateN,1,10)='2004-01-01'支持这句
      

  10.   

    如果dateN是varchar2类型的话
    select * from tableN where to_date(dateN,'yyyy-mm-dd')='2004-01-01'
    如果dateN是date类型的话
    select * from tableN where to_char(dateN,'yyyy-mm-dd')='2004-01-01'