<?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: Cannot select by attributes with GDB_TO_DATE field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305289#M23708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't know where your data comes from? Just saw your example.&lt;/P&gt;&lt;P&gt;If I have a date field in a file gdb I have to quercy it in the select by attributes dialog in ArcMaP like this?&lt;/P&gt;&lt;P&gt;date = date '2019-11-18 16:32:01'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Nov 2019 15:44:56 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2019-11-18T15:44:56Z</dc:date>
    <item>
      <title>Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305283#M23702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Has anybody encountered this problem? I have tried using both a datetime object and a string formatted object in the query and neither work in either python or ArcMap. I am trying to select a record by both its GlobalID and a specific time in the GDB_TO_DATE field on a query layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;coveyObsvRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&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;'{1309DFFD-04B3-4F13-9962-C1C378F1F228}'&lt;/SPAN&gt;
toDate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fromDate&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;
query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"GlobalID = '{0}' and GDB_TO_DATE = '{1}'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;coveyObsvRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; toDate&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#query prints as GlobalID = '{1309DFFD-04B3-4F13-9962-C1C378F1F228}' and GDB_TO_DATE = '2019-11-18 13:58:04'‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I select by just using the GlobalID, I can return the records, so it's obviously a problem with the TO_DATE field, but I can't figure it out. I can see the record blatanly in the archive table:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/473703_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/473704_Capture1.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1:58:04 is really stored as 13:58:04 in the database and you will see as much in the ArcMap select by attributes dialog)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305283#M23702</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-11T14:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305284#M23703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What happens if you use:&amp;nbsp; .&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;toDate &lt;SPAN class=""&gt;=&lt;/SPAN&gt; fromDate&lt;SPAN class=""&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'%Y-%m-%d &lt;/SPAN&gt;&lt;/CODE&gt;%I:%M:%S %p') ?&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:48:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305284#M23703</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2019-11-18T14:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305285#M23704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the suggestion but unfortunately that doesn't work either (and I put in the missing colon).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2019 14:58:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305285#M23704</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2019-11-18T14:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305286#M23705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe 11/18/2019 doesn't fit to your code?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:06:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305286#M23705</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2019-11-18T15:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305287#M23706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure what you mean. You could reformat the datetime into '%m/%d/%Y %I:%M:%S %p' if you wanted to. When you use a datetime field, it automatically formats it to 11/18/2010 H:M:S AM/PM. When it's in the actual database it is formatted as 2019-11-18 H:M:S - this is the one that should logically work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only workaround I can find is by making another query layer and using a&amp;nbsp;&lt;STRONG&gt;&amp;gt;=&lt;/STRONG&gt; operator instead of an = operator. Not very helpful because I need to maintain my current query layer for iteration and if I create a new one on the same set of data, it erases my last query layer. You also cannot select a single record this way, even when using a combination of GDB_FROM_DATE &amp;gt;= and GDB_TO_DATE &amp;lt;= language.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;queryLyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeQueryLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;collector_db_con&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'output'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; "select &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; 
COVEYOBSERVATIONTEST where GlobalID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'{0}'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; GDB_TO_DATE &lt;SPAN class="operator token"&gt;&amp;gt;=&lt;/SPAN&gt; 
&lt;SPAN class="string token"&gt;'{1}'&lt;/SPAN&gt;"&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;coveyObsvRow&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; toDate&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#toDate is a datetime object, not a string‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:37:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305287#M23706</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-11T14:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305288#M23707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found another workaround. In my case, I needed a field that was unique to the record I was trying to select and I can obtain that field using a search cursor (I'm already using an update cursor in my script though so I just grabbed it from that). GDB_ARCHIVE_OID is the only unique field for an archived record that is not a date. Since dates don't work, I had to go with this. This probably is not a solution for everyone though, so I am leaving this question unanswered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:42:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305288#M23707</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2019-11-18T15:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot select by attributes with GDB_TO_DATE field</title>
      <link>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305289#M23708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't know where your data comes from? Just saw your example.&lt;/P&gt;&lt;P&gt;If I have a date field in a file gdb I have to quercy it in the select by attributes dialog in ArcMaP like this?&lt;/P&gt;&lt;P&gt;date = date '2019-11-18 16:32:01'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2019 15:44:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-select-by-attributes-with-gdb-to-date-field/m-p/305289#M23708</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2019-11-18T15:44:56Z</dc:date>
    </item>
  </channel>
</rss>

