我必须使用FETCH XML获取数据,其中参数将为年,而我的CRM中的字段是日期时间字段。那么有没有办法根据月份获取数据。
例如:发布日期:2016年2月12日 报告参数:2016
然后我必须根据月份得到计数,因此根据示例2月计数将是1.
答案 0 :(得分:1)
据我所知,仅使用年份过滤查询是不可能的,因此可能的解决方法是创建开始日期(01/01 / YYYY)和结束日期(31/12 / YYYY)和使用“On or after”和“On or before”运算符。为了获得每月的计数,您可以使用dategrouping参数。
以下是一个示例(2016年按月创建的联系人):
<fetch aggregate="true" >
<entity name="contact" >
<attribute name="createdon" alias="month" groupby="true" dategrouping="month" />
<attribute name="contactid" alias="count" aggregate="count" />
<filter>
<condition attribute="createdon" operator="on-or-after" value="01/01/2016" />
<condition attribute="createdon" operator="on-or-before" value="12/31/2016" />
</filter>
</entity>
</fetch>