要的时间格式是:2008-03-21 00:00:00
必须要带时分秒且都为0。谢谢

解决方案 »

  1.   

    select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;select to_char(sysdate,'yyyy-mm-dd 00:00:00') from dual;
    == 思想重于技巧 ==
      

  2.   

    感谢这么快速,
    经过我测试,
    一、select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual; 
    得出的结果有时分秒,但是不为0!不合要求!失败二、select to_char(sysdate,'yyyy-mm-dd 00:00:00') from dual; 
    数据库报错:date format not recognized
      

  3.   

    select to_char(sysdate,'yyyy-mm-dd') | ' 00:00:00' from dual; 
    == 思想重于技巧 ==
      

  4.   

    问题是这样的,表中有个字段load_time
    时间格式是2008-03-01 12:40:50我需要按日期查询一天的数据,因为表数据是千万级别的,
    所以要将传递进去的数格式转换成2008-03-01 00:00:00selct * from aa where load_time>=2008-03-01 00:00:00
      

  5.   

    selct * from aa where load_time>= to_date('2008-03-01','yyyy-mm-dd');
    == 思想重于技巧 ==
      

  6.   

    select * from aa where to_date(load_time,'yyyy-MM-dd')>= to_date('2008-03-01','yyyy-MM-dd'); 完美答案,收分
      

  7.   

    请问下,转换load_time成本高不 高,
    表AA可是有几千万的数据哦
    ===============================================================================
    select * from aa where to_date(load_time,'yyyy-MM-dd')>= to_date('2008-03-01','yyyy-MM-dd');  完美答案,收分 
      

  8.   

    成本会有点高,但是你表建的就有问题,这个字段本来就该建成DATE,你现在放置日期,成本问题就是因为当时的设计造成的
    ,用下面的这个的成本应该差不多,因为是字符比较,数据库中日期比较远远要高于字符比较。另外,讲一下,你所需要的00:00:00为什么给你丢弃了,因为日期查询,不写时分秒的格式,默认就是从00:00:00开始
    select * from aa where load_time>= '2008-03-01';   
      

  9.   

    我的程序.数据.DBA.交流QQ群6955562 
      

  10.   

    load_time 是字符型?不用转换1 
    select * from aa where load_time>= '2008-03-01';2  select * from aa where load_time>= to_char(sysdate,'yyyy-mm-dd');
    == 思想重于技巧 ==
      

  11.   

    非常感谢各位无私的帮助,
    刚刚有看到别人写的代码,稍做了修改,
      select  to_date(to_char(sysdate, 'yyyymmdd'),'yyyymmdd')+1/(24*60*60)  
      from dual很遗憾得出的结果是:2008-3-23 0:00:01有一秒,不知道那位能取到2008-3-23 0:00:00
    虽然这么说,但俺还是想知道怎么取?嘿嘿,困惑很久
    =============================================================================
    另外,讲一下,你所需要的00:00:00为什么给你丢弃了,因为日期查询,不写时分秒的格式,默认就是从00:00:00开始 
    select * from aa where load_time>= '2008-03-01';    
      

  12.   

    Select trunc(load_time) From dual
      

  13.   

    select to_char(trunc(sysdate),'yyyy-mm-dd hh24:mi:ss') from dual2008-03-24 00:00:00
      

  14.   

    你的Load_time字段是不是日期型的?如果是直接这样比较就行了
    selct * from aa where load_time>=trunc(sysdate) and load_time < trunc(sysdate+1)
      

  15.   

    to_char(trunc(sysdate),'yyyy-mm-dd hh24:mi:ss')
    或者
    to_char(trunc(sysdate),'yyyy-mm-dd') || ' 00:00:00'
      

  16.   

     select to_char(sysdate,'yyyy-mm-dd')||'  00:00:00' from dual;