<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Querying Alfresco on Month of a Date field in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286883#M240013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there any way to query on the basis of month and year of any date field in Alfresco. I'm using aspect where in one of the custom properties is of date type. But I need to query on files based on the month and year of the field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is what I'm doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt; String Query = "select d.*,o.* from cmis:document as d join sc:mine as o on d.cmis:objectid = o.cmis:objectid";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; //"where MONTH(o.sc.createdDateTime) = JAN"&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;And then something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;ItemIterable&amp;lt;QueryResult&amp;gt; results = session.query(Query, false);&lt;BR /&gt;for(QueryRsult qr : results){&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Calendar cal = (Calendar) qr.getPropertyValueByQueryName("o.sc:createdDateTime");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Integer month = cal.get(Clendar.MONTH);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; Integer year = cal.get(Clendar.YEAR);&lt;BR /&gt;//Select the required month/year and then proceed&lt;BR /&gt;}&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;But in this approach every time we have to loop through all the results. It will really helpful if I can query on the month of sc:createdDateTime&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Jan 2015 06:23:37 GMT</pubDate>
    <dc:creator>smsoumitra</dc:creator>
    <dc:date>2015-01-19T06:23:37Z</dc:date>
    <item>
      <title>Querying Alfresco on Month of a Date field</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286883#M240013</link>
      <description>Is there any way to query on the basis of month and year of any date field in Alfresco. I'm using aspect where in one of the custom properties is of date type. But I need to query on files based on the month and year of the field.This is what I'm doing.&amp;nbsp;  String Query = "select d.*,o.* from cmis:doc</description>
      <pubDate>Mon, 19 Jan 2015 06:23:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286883#M240013</guid>
      <dc:creator>smsoumitra</dc:creator>
      <dc:date>2015-01-19T06:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: Querying Alfresco on Month of a Date field</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286884#M240014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;unfortunately, the CMIS specification as far as I know does not provide a facility to query for natural year, month or date in isolation (without a complete timestamp) on date fields. But you may be able to use Alfresco full text support to do a simple contains check in your CMIS query, e.g. use CONTAINS('cmis:creationDate:\'2015-01-??\'') to select a specific month and retrieve only the relevant subset of documents (for each year - unfortunately it seems you can't use ???? wildcards for the year to retrieve all the January documents regardless of year).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Axel&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 09:31:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286884#M240014</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2015-01-19T09:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Querying Alfresco on Month of a Date field</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286885#M240015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that asing a comparison predicate will make the point. Here is an example if you want to get documents with creationDate in January 2015 :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT * FROM cmis:document WHERE cmis:creationDate &amp;gt;= TIMESTAMP '2015-01-01T00:00:00.000+00:00' AND cmis:creationDate &amp;lt; TIMESTAMP '2015-02-01T00:00:00.000+00:00'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 17:18:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-alfresco-on-month-of-a-date-field/m-p/286885#M240015</guid>
      <dc:creator>mlagneaux</dc:creator>
      <dc:date>2015-01-19T17:18:59Z</dc:date>
    </item>
  </channel>
</rss>

