<?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 Re: ArcGIS API for python: find latest items in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729150#M185</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if all this goofiness is still present in more recent versions&amp;nbsp;API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason for it in this&amp;nbsp;specific&amp;nbsp;case&amp;nbsp;was that the API&amp;nbsp;was treating the values supplied in this way as strings, rather than as numbers. While numerically &lt;SPAN style="background-color: #ffffff;"&gt;000001 equals 1, "&lt;SPAN&gt;000001" and "1"&amp;nbsp;are not&amp;nbsp;equal.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;It also wanted&amp;nbsp;values in microseconds, rather than milliseconds. Hence the additional factor of 1000 in the conversion.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;-peter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Nov 2019 16:02:28 GMT</pubDate>
    <dc:creator>PeterKnoop</dc:creator>
    <dc:date>2019-11-14T16:02:28Z</dc:date>
    <item>
      <title>ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729146#M181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I created a script to find the&amp;nbsp;latest uploaded items on ArcGIS Online using ArcGIS API for python.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no errors but it does not find anything. I search for items uploaded in last&amp;nbsp; 7, 30 or even 100 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It finds few items if I search from 2009 till now but even then I don't think it shows everything.&lt;/P&gt;&lt;P&gt;Did I miss something? Do I need to format query differently? Out of ideas...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;gis = GIS("&lt;A href="http://xxxxxx.maps.arcgis.com"&gt;http://arcgisonline.maps.arcgis.com&lt;/A&gt;", "username", "password", proxy_host = "example", proxy_port = 0000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# how far back does the search go? user input&lt;/P&gt;&lt;P&gt;input_days = input("how many days back do you want to search? ")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# based on days, that user has entered, calculate the date to start the search from in unix time, in seconds as per query format requirements&lt;/P&gt;&lt;P&gt;import time&lt;/P&gt;&lt;P&gt;now = time.time()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# converting input to integer, then to seconds, then calculating date from which items where uploaded to unix time&lt;/P&gt;&lt;P&gt;days = int(input_days)&lt;/P&gt;&lt;P&gt;days_in_seconds = days*24*60*60&lt;/P&gt;&lt;P&gt;dateFrom_s = now - days_in_seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# function to format unix time in seconds to the format required&lt;/P&gt;&lt;P&gt;def timeQuery(time_in_seconds):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # convert time to milliseconds, then to interger to remove everything after point, then convert to string and add 6x0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ('000000'+str(int(time_in_seconds*1000)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;nowQ = timeQuery(now)&lt;/P&gt;&lt;P&gt;beforeQ = timeQuery(dateFrom_s)&lt;/P&gt;&lt;P&gt;print(beforeQ)&lt;/P&gt;&lt;P&gt;print(nowQ)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;search_result = gis.content.search(query = "uploaded: [beforeQ TO nowQ]")&lt;/P&gt;&lt;P&gt;#search_result = gis.content.search(query = "*")&lt;/P&gt;&lt;P&gt;# some date in 2009 in unix time, ms, and six zeros at the front as per query requirement 0000001259692864000&amp;nbsp;&lt;/P&gt;&lt;P&gt;search_result2 = gis.content.search(query = "uploaded: [0000001259692864000 TO 0000001542676158153]")&lt;/P&gt;&lt;P&gt;#search_result = gis.content.search(query = "*")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print(search_result)&lt;/P&gt;&lt;P&gt;print(search_result2)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2018 01:42:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729146#M181</guid>
      <dc:creator>lxd</dc:creator>
      <dc:date>2018-11-20T01:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729147#M182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The main issue is that the time&amp;nbsp;value from which you are starting, &lt;SPAN style="font-family: 'andale mono', monospace;"&gt;time.time()&lt;/SPAN&gt;, is in a format that needs an additional conversion.&amp;nbsp;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px; font-family: 'andale mono', monospace;"&gt;str(int(time_in_&lt;/SPAN&gt;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;seconds*1000)))&lt;/SPAN&gt; should be&amp;nbsp;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;str(int(time_in_&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;seconds*1000000)))&lt;/SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px;"&gt;&lt;SPAN&gt;As ArcGIS Online stores the "uploaded"&amp;nbsp;time in UTC, you probably also want to set your "now"&amp;nbsp;using UTC as well. Your code is using your local time zone.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #666666; background-color: #ffffff; font-size: 14px;"&gt;&lt;SPAN&gt;For instance, you might&amp;nbsp;try something like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS

gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime

input_days &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; input&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"how many days back do you want to search? "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

now_dt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;utcnow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
then_dt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; now_dt &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;timedelta&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;days&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input_days&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

now &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'000000'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;now_dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;timestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'000'&lt;/SPAN&gt;
then &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'000000'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;then_dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;timestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'000'&lt;/SPAN&gt;

items &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
 query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'uploaded: ['&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; then &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' TO '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; now &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;']'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
 max_items&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10000&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'items found: '&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&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;/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;/BLOCKQUOTE&gt;&lt;P&gt;Also, the default for&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; max_items&amp;nbsp;&lt;/SPAN&gt;with&lt;SPAN style="font-family: 'andale mono', monospace;"&gt; gis.content.search &lt;/SPAN&gt;is 10, so if the search finds more than ten items, it will only return the first ten results. If you are expecting more than&amp;nbsp;ten results, then you&amp;nbsp;will want to increase&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;max_items&amp;nbsp;&lt;/SPAN&gt;appropriately.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:08:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729147#M182</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2021-12-12T07:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729148#M183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An example for the &lt;A href="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Range Search&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;{ uploaded: [0000001259692864000 TO 0000001260384065000] }&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Peter is right about how ArcGIS Online stores the timestamp, it's UTC and in a string format.&amp;nbsp;Here is the tested and working code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# UTC time&lt;/SPAN&gt;
now_dt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;utcnow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
then_dt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; now_dt &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; timedelta&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;days&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input_days&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# construct the string for range search, see ESRI doc for string format&lt;/SPAN&gt;
now &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'000000'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;now_dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;timestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'000'&lt;/SPAN&gt;
then &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'000000'&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;then_dt&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;timestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'000'&lt;/SPAN&gt;

items &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
 query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'uploaded: ['&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; then &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;' TO '&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; now &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;']'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
 max_items&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10000&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# sort the items by modified date&lt;/SPAN&gt;
items2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sorted&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;key&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;lambda&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;modified&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; item &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; items2&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; str_time &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fromtimestamp&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;modified&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Modified Time:{0}, Title:{1}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;str_time&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&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;/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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:08:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729148#M183</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2021-12-12T07:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729149#M184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a range search against portal and it's working using the date formatting as you have outlined up above but I'm really confused still about it.&amp;nbsp; Why are we appending a string of zeros to the left side of a number?&amp;nbsp; Isn't 000001 the same as just 1?&amp;nbsp; And if portal is storing dates in milliseconds, and the timestamp function gives you seconds, wouldn't now_dt.timestamp()*1000 give you milliseconds?&amp;nbsp; Why are you multiplying by 1,000,000 and not 1,000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully something fundamental that I'm missing here can set me straight.&amp;nbsp; THANKS!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Nov 2019 23:42:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729149#M184</guid>
      <dc:creator>deleted-user-997AEHHSB7nZ</dc:creator>
      <dc:date>2019-11-12T23:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729150#M185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if all this goofiness is still present in more recent versions&amp;nbsp;API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason for it in this&amp;nbsp;specific&amp;nbsp;case&amp;nbsp;was that the API&amp;nbsp;was treating the values supplied in this way as strings, rather than as numbers. While numerically &lt;SPAN style="background-color: #ffffff;"&gt;000001 equals 1, "&lt;SPAN&gt;000001" and "1"&amp;nbsp;are not&amp;nbsp;equal.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;It also wanted&amp;nbsp;values in microseconds, rather than milliseconds. Hence the additional factor of 1000 in the conversion.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;-peter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2019 16:02:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729150#M185</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2019-11-14T16:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS API for python: find latest items</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729151#M186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting - I get it that "000001" are "1"&amp;nbsp;different strings - but really?&amp;nbsp; They're the same number - aren't we dealing with numbers here?&amp;nbsp; That seems like a design flaw.&amp;nbsp; I've searched all the docs and I'm not finding anything about magic zero string logic.&amp;nbsp; Did I miss something?&amp;nbsp; And microseconds?&amp;nbsp; Don't see that anywhere in the doc either.&amp;nbsp; In fact, in the API docs there's a &lt;A href="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm"&gt;link to the range search ability of the REST API&lt;/A&gt; and it says to use milliseconds, nothing about microseconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not for your tip above I'm afraid there's no way I could have figured out how to use&amp;nbsp;the ArcGIS API for Python to query the rest API by date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FWIW - I was using the ArcGIS API for Python v1.5.1 which came with ArcGIS Pro v2.3 - hitting a 10.5.1 ArcGIS Portal.&amp;nbsp; I am tempted to try a later version of the API.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Nov 2019 18:20:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-find-latest-items/m-p/729151#M186</guid>
      <dc:creator>deleted-user-997AEHHSB7nZ</dc:creator>
      <dc:date>2019-11-14T18:20:21Z</dc:date>
    </item>
  </channel>
</rss>

