要搜索从12/2/2005到1/3/2005每天18:00到第二天早晨7:00的纪录,sql怎么写?高手帮帮忙啊!

解决方案 »

  1.   

    select * from tableName where  to_char(datefield,'hh24:mi') between '10:00' and '15:00' and datefield between '12-2月-05' and '19-3月-05';
      

  2.   

    每天10:00到15:00的
    select * from tableName where  to_char(datefield,'hh24:mi') between '10:00' and '15:00' and datefield between '12-2月-05' and '2-3月-05';每天18:00到7:00的
    select * from tableName where  to_char(datefield,'hh24:mi') not between '7:00' and '18:00' and datefield between '12-2月-05' and '2-3月-05';
      

  3.   

    第二句应该是这样
    select * from tableName where  to_char(datefield,'hh24:mi') not between '07:00' and '18:00' and datefield between '12-2月-05' and '2-3月-05';
      

  4.   

    (1)
    select *
      from tableName
     where to_char(datefield, 'hh24:mi') between '10:00' and '15:00'
       and datefield between to_date('20050212', 'YYYYMMDD') and
           to_date('20050301', 'YYYYMMDD');
    (2)
    select *
      from tableName
     where to_char(datefield, 'hh24:mi') between '18:00' and '23:59'
       and datefield between to_date('20050212', 'YYYYMMDD') and
           to_date('20050301', 'YYYYMMDD');
    union
    select *
      from tableName
     where to_char(datefield, 'hh24:mi') between '00:00' and '07:00'
       and datefield between to_date('20050213', 'YYYYMMDD') and
           to_date('20050302', 'YYYYMMDD');
      

  5.   

    lynx(lynx)的比较好,zrtl(刚从软件园回来)的日期的比较上好像有点问题。
      

  6.   

    我要使 between 有个疑问表里有3条数据1)出国时间:  2000-2-1 
       回国时间:  2000-11-41)出国时间:  2000-4-1 
       回国时间:  2000-12-41)出国时间:  2000-5-1 
       回国时间:  2001-3-4我想查询在2000年到2001年出国的数据,用between可以吗?(以出国时间为准,这3条数据都应该被查询出来)请问这样的SQL如何些?先谢谢前辈们了!
      

  7.   

    select *
      from table t
     where to_char(t.出国时间, 'YYYY') between '2000' and '2001'
      

  8.   

    'YYYY' 这个是啥?在'2000' 和 '2001'的位置,我需要接受使用者的数据。aaa = request("out")
    bbb =  request("in")
    sql = "select * from Times where Time_out between '"aaa"' and '"bbb"'"怎么没值?
      

  9.   

    aaa = request("out")
    bbb =  request("in")
    sql = "select * from Times
    where to_char(Time_out , 'YYYY') between '"aaa"' and '"bbb"'"