DATEPART ( year , date ) dateIs an expression that returns a datetime or smalldatetime value, or a character string in a date format. Use the datetime data type only for dates after January 1, 1753. Store dates as character data for earlier dates. When entering datetime values, always enclose them in quotation s. Because smalldatetime is accurate only to the minute, when a smalldatetime value is used, seconds and milliseconds are always 0.If you specify only the last two digits of the year, values less than or equal to the last two digits of the value of the two digit year cutoff configuration option are in the same century as the cutoff year. Values greater than the last two digits of the value of this option are in the century that precedes the cutoff year. For example, if two digit year cutoff is 2049 (default), 49 is interpreted as 2049 and 2050 is interpreted as 1950. To avoid ambiguity, use four-digit years.

解决方案 »

  1.   

    select * from table where mytime>2003/1/ and mytime<2004/1/1
      

  2.   

    如果数据库的数据类型是datetime,那就用year函数取如year(字段名)
    如果不是用substring函数也可以如SELECT au_lname, SUBSTRING(year, 1, 4)
    FROM authors
      

  3.   

    对不起错了,应该是select* from table where SUBSTRING(year, 1, 4)='2003'
      

  4.   

    可以使用模糊查询。
    string @Date = "2003";
    例如:sqlstr = "Select * From 表名 Where 时间字段 like '"+@Date+"'%";
      

  5.   

    Select * from Table where year(Rq)=2002