<?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 Search for PortalItem by Date Created or Modified in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/search-for-portalitem-by-date-created-or-modified/m-p/150508#M1689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I asked this in the ArcGIS Enterprise group&amp;nbsp;&lt;A href="https://community.esri.com/thread/229570" target="_blank"&gt;Search by Date Created or Modified&lt;/A&gt;&amp;nbsp;because I think it is really a syntax issue with search, but I am trying to do from a Runtime application so checking here.&amp;nbsp; I want to run a search for PortalItems in a group using the Date Modified of the item.&amp;nbsp; But I cannot seem to get this correct because it never returns results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code in Runtime is pretty straightforward:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;//Portal uses time in Unix time &amp;gt; milliseconds
DateTimeOffset offset = new DateTimeOffset(new DateTime(2018, 1, 1));
long unixTime = offset.ToUnixTimeMilliseconds();
long unix2Time = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();

//Query by group and pass in query string
parameters = 
       PortalQueryParameters.CreateForItemsOfTypeInGroup(PortalItemType.CodeSample,
            group.GroupId, $"modified:[{unixTime} TO {unix2Time}]");

parameters.Limit = 50;

PortalQueryResultSet&amp;lt;PortalItem&amp;gt; itemResultSet = await portal.FindItemsAsync(parameters);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/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;P&gt;&lt;/P&gt;&lt;P&gt;In the sample I am using a date range from before I setup portal to today, I know the items are in that range.&amp;nbsp; I have also tried to use created instead of modified just to see if it is an issue with modified, and used 0 as a start date.&amp;nbsp; Based on the the API search reference this is the format to use&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Search reference—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this example the Find return no results.&amp;nbsp; If I remove the date query piece I get all the CodeSample items in the group as expected just not filtered by date.&amp;nbsp; Looking at the&amp;nbsp;PortalQueryParameters you can see the query is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;type:"Code Sample" AND group:"006591a762ce4705827561768866d03c" AND (modified:"[1259692864000 TO 1551311005864]")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I go into Portal and run the search directly no results, run without date component and it works fine.&amp;nbsp; I have tried just running queries in Portal using the date component without anything else and I can never get any results to return.&amp;nbsp; So it would seem to me the documented syntax for running these queries is incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone done anything to query for portal items based on date modified/created and would know the proper syntax for doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;-Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:06:56 GMT</pubDate>
    <dc:creator>JoeHershman</dc:creator>
    <dc:date>2021-12-11T08:06:56Z</dc:date>
    <item>
      <title>Search for PortalItem by Date Created or Modified</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/search-for-portalitem-by-date-created-or-modified/m-p/150508#M1689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I asked this in the ArcGIS Enterprise group&amp;nbsp;&lt;A href="https://community.esri.com/thread/229570" target="_blank"&gt;Search by Date Created or Modified&lt;/A&gt;&amp;nbsp;because I think it is really a syntax issue with search, but I am trying to do from a Runtime application so checking here.&amp;nbsp; I want to run a search for PortalItems in a group using the Date Modified of the item.&amp;nbsp; But I cannot seem to get this correct because it never returns results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code in Runtime is pretty straightforward:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;//Portal uses time in Unix time &amp;gt; milliseconds
DateTimeOffset offset = new DateTimeOffset(new DateTime(2018, 1, 1));
long unixTime = offset.ToUnixTimeMilliseconds();
long unix2Time = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();

//Query by group and pass in query string
parameters = 
       PortalQueryParameters.CreateForItemsOfTypeInGroup(PortalItemType.CodeSample,
            group.GroupId, $"modified:[{unixTime} TO {unix2Time}]");

parameters.Limit = 50;

PortalQueryResultSet&amp;lt;PortalItem&amp;gt; itemResultSet = await portal.FindItemsAsync(parameters);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/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;P&gt;&lt;/P&gt;&lt;P&gt;In the sample I am using a date range from before I setup portal to today, I know the items are in that range.&amp;nbsp; I have also tried to use created instead of modified just to see if it is an issue with modified, and used 0 as a start date.&amp;nbsp; Based on the the API search reference this is the format to use&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Search reference—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this example the Find return no results.&amp;nbsp; If I remove the date query piece I get all the CodeSample items in the group as expected just not filtered by date.&amp;nbsp; Looking at the&amp;nbsp;PortalQueryParameters you can see the query is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;type:"Code Sample" AND group:"006591a762ce4705827561768866d03c" AND (modified:"[1259692864000 TO 1551311005864]")&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I go into Portal and run the search directly no results, run without date component and it works fine.&amp;nbsp; I have tried just running queries in Portal using the date component without anything else and I can never get any results to return.&amp;nbsp; So it would seem to me the documented syntax for running these queries is incorrect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone done anything to query for portal items based on date modified/created and would know the proper syntax for doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;-Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/search-for-portalitem-by-date-created-or-modified/m-p/150508#M1689</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2021-12-11T08:06:56Z</dc:date>
    </item>
  </channel>
</rss>

