我用的是delphi+access数据库select DATEPART("yyyy", in_date) as y,DATEPART("mm", in_date) as m from table1 group by DATEPART("yyyy", in_date),DATEPART("mm", in_date)以上语句无法执行通过,提示“......无效的函数调用......”
如把数据库换成“MSSQL”就没问题.
以下语句在access中也没问题
select DATEPART("yyyy", in_date) as y from table1 group by DATEPART("yyyy", in_date)请教各位大师:问题出在哪在access中应如何解决?

解决方案 »

  1.   

    access 支持的 sql 语句并没有 sql server 那么多,
    很少用access作复杂的查询,如果需要,可以在 dataset 对应的字段的 onGetText 处理
      

  2.   

    select DATEPART("yyyy", in_date) as y,DATEPART("mm", in_date) as m from table1 group by DATEPART("yyyy", in_date),DATEPART("mm", in_date)
    改为:select DATEPART("yyyy", in_date) as y,DATEPART("mm", in_date) as m from table1 group by DATEPART("yyyy", in_date)
      

  3.   

    DATEPART("mm", in_date)//
    写成datepart("m",in_date)
      

  4.   

    access可能有点不同,我用过oracle数据库的,好像时间函数不是这样。学习!!
      

  5.   

    lianshaohua(永远深爱一个叫“...... ”的好女孩儿!) 
    你的方法得不到我想要的数据集
    whbo(王红波(年轻人,要有所作为)
    用你的方法结果一样,还是不行
    不过还是谢谢两位,不知楼下没有没更好的,拜托各位了,急用啊
      

  6.   

    看看access的函数帮助
    有很多函数和sqlserver或者其他的不一样的
      

  7.   

    你的时间格式是yyyy*mm*dd吗? 其中*可以是-或者/
    如果是,既然在access不能这样写,你就只好换一种方法了。如下作一下参考吧:select substring(Trim(datetimeToStr(in_date)),1,4 ) as y, substring(Trim(datetimeToStr(in_date)),6,2 ) as m from  table1group by  substring(Trim(datetimeToStr(in_date)),1,4 ) ,substring(Trim(datetimeToStr(in_date)),6,2 ) 
      

  8.   

    whbo(王红波(年轻人,要有所作为)) 
    你的方法果然可以啊,刚试了一下,昨天没去试!不好意思
    谢了!