以前用SQLServer时,只要用where year(日期)=2005就可以找出2005年的,月份也是一样。可在Access中不行,用where datepart(year,日期)=2005也不行,救命啊!!

解决方案 »

  1.   

    ACCESS不支持DATEPART函数..可以用YEAR
      

  2.   

    select * form yourtable where year(日期)=someyear and month(日期)=somemonth and day(日期)=someday
    up that is only a sample ,there is not a actual means
      

  3.   

    例如:
    sSql = "insert into search(searchdate,amount) select year(checkdate) & '年',sum(amount) as amountsum from [check] where year(checkdate) between " & Me.cmbYear(2).Text & " and " & Me.cmbYear(3).Text & " group by year(checkdate) order by year(checkdate)"
      

  4.   

    谢谢大家了,原来是where和group by的位置换了