要求求系统前一天的时间,前天00;00:00到今天00:00:00  格式和系统时间格式一样ORACLE数据库

解决方案 »

  1.   

    select * from tablename where columnname
    between to_date(to_char(sysdate-1,'yyyy-mm-dd'),'yyyy-mm-dd') and to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd')
      

  2.   

    sysdate取'yyyy-mm-dd'時候,系統默認的時分秒就是00:00:00
    或者換一種寫法就是
    select * from tablename where to_char(columnname,'yyyy-mm-dd hh24:mi:ss')
    between to_char(sysdate-1,'yyyy-mm-dd') || ' 00:00:00' and to_char(sysdate,'yyyy-mm-dd') || ' 00:00:00'還是第一種比較好.有columnname的index還能用的上
      

  3.   

    select a.* between to_date(to_char(sysdate-1,'yyyy-mm-dd')||' 00:00:00','yyyy-mm-dd hh24:mi ss') and to_date(to_char(sysdate,'yyyy-mm-dd')||' 00:00:00','yyyy-mm-dd hh24:mi ss')
      

  4.   

    select a.* between to_date(to_char(sysdate-1,'yyyy-mm-dd')||' 00:00:00','yyyy-mm-dd hh24:mi ss') and to_date(to_char(sysdate,'yyyy-mm-dd')||' 00:00:00','yyyy-mm-dd hh24:mi ss')

    select * from tablename where columnname
    between to_date(to_char(sysdate-1,'yyyy-mm-dd'),'yyyy-mm-dd') and to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd')
    是一樣的
      

  5.   

    不一样的 没有所说的默认时分秒的,我用的oracle 9i的  不知道你用的什么 我试了好象不行