<?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: Query feature if an attribute is null after 180 days of date on another attribute? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746478#M57696</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The month and day are correct but the year is 2019 instead of 2018?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Oct 2018 18:12:07 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2018-10-05T18:12:07Z</dc:date>
    <item>
      <title>Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746476#M57694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking for a sample ArcPy script I can modify for my use. Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 16:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746476#M57694</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-10-05T16:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746477#M57695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps&amp;nbsp; (you could remove time from formatting, if desired):&lt;/P&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; datetime &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; timedelta

date_past &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;now&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; timedelta&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;days&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;180&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# you can add/subtract as required&lt;/SPAN&gt;

wc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Field IS NULL AND DateField &amp;lt; DATE '{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;date_past&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;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; wc
&lt;SPAN class="comment token"&gt;# Field IS NULL AND DateField &amp;lt; DATE '2018-04-08 09:25:35'‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746477#M57695</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T07:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746478#M57696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The month and day are correct but the year is 2019 instead of 2018?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 18:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746478#M57696</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-10-05T18:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746479#M57697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Typo on my part, an extra minus in days=180&amp;nbsp; (updated original code):&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;date_past &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; datetime&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;now&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; timedelta&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;days&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;180&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 18:15:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746479#M57697</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-10-05T18:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746480#M57698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome! Thanks for your help on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 18:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746480#M57698</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-10-05T18:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746481#M57699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used the code you supplied but noticed it's returning everything 180 days or older. I only want results that fall exactly 180 days from current date.&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;permits&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Date_Accepted = date '{}' AND Fee_Paid Is NULL"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;notice&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"&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="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 18:50:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746481#M57699</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-10-05T18:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746482#M57700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My bet is&amp;nbsp;to change the&amp;nbsp; &amp;nbsp;&amp;lt;&amp;nbsp; to&amp;nbsp; &amp;nbsp;=&amp;nbsp; &amp;nbsp;and you should be good to go:‍&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;

wc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Field IS NULL AND DateField = DATE '{}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;date_past&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;&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746482#M57700</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T07:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746483#M57701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try 'Between' and set hours = '00:00:00' and '23:59:59' (between will get both these values and all those inbetween).&amp;nbsp; Or add another day with timedelta.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;dp = date_past.strftime("%Y-%m-%d")

wc = "Field IS NULL AND DateField BETWEEN DATE '{} 00:00:00' AND DATE '{} 23:59:59' ".format(dp,dp))
‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:45:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746483#M57701</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T07:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746484#M57702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When dealing with date/time, I probably wouldn't use "=" in the query.&amp;nbsp; See &lt;A href="https://community.esri.com/migrated-users/3420"&gt;Joshua Bixby&lt;/A&gt;‌'s&amp;nbsp;second comment in &lt;A _jive_internal="true" href="https://community.esri.com/thread/222092-querying-agol-feature-service-by-date-range-in-arcgis-pro"&gt;this thread&lt;/A&gt;&amp;nbsp;with ESRI's explanation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 19:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746484#M57702</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-10-05T19:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746485#M57703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After I read you post with 'between' I realized that.....&amp;nbsp; thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 19:42:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746485#M57703</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2018-10-05T19:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query feature if an attribute is null after 180 days of date on another attribute?</title>
      <link>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746486#M57704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And after I re-read Esri's comment, I started thinking milliseconds.&amp;nbsp; So "23:59:59" could also miss "23:59:59.9".&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2018 19:46:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-feature-if-an-attribute-is-null-after-180/m-p/746486#M57704</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2018-10-05T19:46:27Z</dc:date>
    </item>
  </channel>
</rss>

