2003年7-8月:
select * from yourtabel where edate between '2003-07-01' and '2003-09-01'2000年-2001年:
select * from yourtabel where edate between '2000-01-01' and '2002-01-01'2003年7月5日至7月8日:
select * from yourtabel where edate between '2003-07-05' and '2003-07-09'

解决方案 »

  1.   

    7-8月:
    select * from yourtabel where datepart(month,edate) between 7 and 82000年-2001年:
    select * from yourtabel where datepart(year,edate) between 2000 and 2001
    7月5日至7月8日:
    select * from yourtabel where substring(convert(char(12),edate,120),6,5) between '07-05' and '07-08'
      

  2.   

    year(date字段) in (2000,2001)
    month(date字段) in(7,8)
    right(convert(varchar(8),getdate(),112),3) between 705 and 708
      

  3.   

    用between...and ...容易产生前后两个时间端点的歧义,不如直接用>=<
    2003年7-8月:
    select * from yourtabel where edate >='2003-07-01' and edate <'2003-09-01'2000年-2001年:
    select * from yourtabel where edate >='2000-01-01' and edate <'2002-01-01'2003年7月5日至7月8日:
    select * from yourtabel where edate >='2003-07-05' and edate <'2003-07-09'
      

  4.   

    大于小于比较你肯定会啦.
    关键是掌握几个与日期相关的函数
    DATEPART
    返回代表指定日期的指定日期部分的整数。语法
    DATEPART ( datepart , date ) 参数
    datepart是指定应返回的日期部分的参数。下表列出了 Microsoft&reg; SQL Server&#8482; 识别的日期部分和缩写。日期部分 缩写 
    year yy, yyyy 
    quarter qq, q 
    month mm, m 
    dayofyear dy, y 
    day dd, d 
    week wk, ww 
    weekday dw 
    Hour hh 
    minute mi, n 
    second ss, s 
    millisecond ms 
      

  5.   

    DAY
    返回代表指定日期的天的日期部分的整数。语法
    DAY ( date ) MONTH
    返回代表指定日期月份的整数。语法
    MONTH ( date )YEAR
    返回表示指定日期中的年份的整数。语法
    YEAR ( date )