本帖最后由 heroshen1988 于 2010-01-13 14:33:43 编辑

解决方案 »

  1.   

    select 事件 from test where time >= 开始时间 and time <= 结束时间
      

  2.   

    这样
    select 事件 from 表 where 开始时间<=time and 结束时间>=time
      

  3.   

    matter(String)   beginTime(Date)  endTime(Date)
      

  4.   


    注意!!那个time是某一年的某一个整月
      

  5.   

    开始日期在5号,结束时间在10号你这个sql语句不就查不到了?
      

  6.   

    select matter from test where time >= beginTime and time <= endTime
      

  7.   

    Oracle  = =!
    select t.事件 from Table t where to_char(t.时间,'YYYY-MM') = '2010-01';
      

  8.   

    select * from yourtable where MONTH( begindate ) between5 and 10
      

  9.   

     上面逻辑有问题,只是测试,关键应该是month之类的函数吧
      

  10.   

    select * from 表 where DATEPART(month, 开始时间)<=月 and DATEPART(month, 结束时间)>=月 and DATEPART(year, 开始时间)=年 and DATEPART(year, 结束时间)=年
      

  11.   

    select * from table where 时间 >= to_char(beginTime,'yyyy-MM') and 时间 <= to_char(beginTime,'yyyy-MM') 
      

  12.   

    select * from test where DATE_FORMAT(beginTime,'%Y%m') = date(如201001) or DATE_FORMAT(endTime,'%Y%m') = date
      

  13.   

    看错了 上面是sql的
    Mysql这样写select * from 表 where month(开始时间) =月 and month(结束时间)=月 and year(开始时间)=年 and year(结束时间)=年 
      

  14.   

    还有一只方法:select * from 表 where extract(year_month from @开始时间) =200909 and extract(year_month from @结束时间)=200909200909是你的年和月的结合
      

  15.   

    所谓正在进行的事件,我理解可分成以下三种情况:
    1、在这个月以前就开始,在这个月后结束的,或还未结束;
    2、在这个月开始的,不管结束不结束,都是这个月进行的,即开始时间在这个月内的;
    3、在这个月结束的,不管什么时候开始,都是这个月进行的,即结束时间在这个月内的。select * from table t 
    where (to_char(t.开始时间, 'YYYY-MM') < '2010-01' 
    and (to_char(t.结束时间, 'YYYY-MM') > '2010-01' or t.结束时间 is null))
    or to_char(t.结束时间, 'YYYY-MM') = '2010-01'
    or to_char(t.开始时间, 'YYYY-MM') = '2010-01'