select * from table where s_time>'2004-12-23 08:03:30' and e_time<'2004-12-23 08:20:30'

解决方案 »

  1.   

    to:ORARichard(没钱的日子......) 
    是s_time              e_time
    谢谢!
      

  2.   

    loveutoo(Mars) 你的语句第一条语句搜索不到呀!
      

  3.   

    loveutoo(Mars) 你的语句第一条记录搜索不到呀!
      

  4.   

    select * from tb where s_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')
      

  5.   

    SELECT * FROM TABNAME 
    WHERE TO_CHAR(s_time, 'yyyymmddhh24miss') > '20041223080330' AND 
        TO_CHAR(e_time, 'yyyymmddhh24miss') < '20041223082030'
      

  6.   

    ORARichard(没钱的日子......)
    和 loveutoo(Mars) 一样,记录集中会少前面和后面两条记录
      

  7.   

    select * from tb where s_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')
      

  8.   

    select * from tb where e_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and s_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')
      

  9.   

    try:SELECT * FROM TABNAME 
    WHERE (s_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')) or
    (s_time<to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss')) or
    (s_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time>to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'));
      

  10.   

    你的语句简化后:
    select * from tb where 2004-12-23 08:01:30>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and 2004-12-23 08:21:30
    <to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')成立么?
    我要的记录集就是上面的列出来的几条?不好意思,你再看一下吧!谢谢!
      

  11.   

    我觉得最好的解决办法是将2004-12-23 08:03:30减5分钟, 将 2004-12-23 08:20:30加5分钟!
    bzszp的语句我测试一下!谢谢!稍等
      

  12.   

    a          s_time              e_time
    1    2004-12-23 08:01:30  2004-12-23 08:06:30
    2    2004-12-23 08:06:30  2004-12-23 08:11:30
    3    2004-12-23 08:11:30  2004-12-23 08:16:30
    4    2004-12-23 08:16:30  2004-12-23 08:21:30
    我想截取:2004-12-23 08:03:30  2004-12-23 08:20:30之间的上面这段数据,sql语句该如何写?
    select * from yourtable where (s_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
    or 
    (s_time < to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss'))
    or
    (s_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
      

  13.   

    select * from yourtable where 
    --取中间数据
    (s_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))or 
    --包含起始数据
    (s_time < to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss'))or
    --包含结束数据
    (s_time < to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss') and e_time > to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss'))
      

  14.   

    在oracle中将开始时间减5分钟,将结束时间加5分钟的sql语句该如何写呀?这样会不会简单些?谢谢!·
      

  15.   

    select * from tb where e_time>to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and s_time<to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')这句不行吗
      

  16.   

    select s_time-5/(24*60),e_time+5/(24*60) from tbname ;
      

  17.   

    ORARichard(没钱的日子......) 的是对的,不行的话 加<= ,>= 如下:
    注意,是e_time用>= 与参数的开始日期比,s_time用>= 与参数的结束日期比。
            select * from tb where e_time>=to_date('2004-12-23 08:03:30','yyyy-mm-dd hh24:mi:ss') and s_time<=to_date('2004-12-23 08:20:30','yyyy-mm-dd hh24:mi:ss')