<?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 Date in Model Builder with Inline Variable in ModelBuilder Questions</title>
    <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1195052#M166</link>
    <description>&lt;P&gt;This did the trick.&amp;nbsp; Thanks for sharing.&amp;nbsp; Will come in handy many times over.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2022 18:36:14 GMT</pubDate>
    <dc:creator>BrendanFordDC</dc:creator>
    <dc:date>2022-07-22T18:36:14Z</dc:date>
    <item>
      <title>Query Date in Model Builder with Inline Variable</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/843682#M163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have had challenges querying date field (in a file geodatabase) within Model Builder when passing a date value using inline variable substitution.&amp;nbsp; After some frustration with many attempts,&amp;nbsp; I figured out a very simple and effective solution that I&amp;nbsp; thought I would share. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Situation&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;You have a model that gets a date value as input parameter (user entered, from an existing field in feature class, etc.) and store as inline variable (e.g. valDate)&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;You want to query a date field (e.g. 'CompletionDate') in existing feature class again the date passed by the inline variable date.&amp;nbsp; For example you want query 'CompletionDate' &amp;gt; valDate in the 'MakeFeatureLayer' tool (see below)&lt;/LI&gt;&lt;LI&gt;You may try a simple syntax as shown below - &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;THIS WILL NOT WORK&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;IMG class="j-img-floatstart image-1 jive-image" height="257" src="https://community.esri.com/legacyfs/online/498173_pastedImage_3.png" style="float: left;" width="422" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/498174_pastedImage_6.png" /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Issue&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Even if the valDate inline variable is defined as a 'Date' is is passed as a string, so you would need to include the reference %valDate% in quotes as such '%valDate%'&lt;/LI&gt;&lt;LI&gt;However, that wouldnt fix issue since the date value passed as string is likely to be in mm/dd/yyyy format (e.g. 07/04/2020) but date format for file geodatabase in SQL query is "date '&amp;lt;date&amp;gt; &amp;lt;time&amp;gt;'" (date '2020-07-04)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Use the CAST function in your SQL query so that it "casts" (i.e. converts) string being passed from valDate to a Date value.&lt;/LI&gt;&lt;LI&gt;See example below - &lt;STRONG style="color: #339966; "&gt;THIS SHOULD WORK&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG style="color: #339966; "&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/498175_pastedImage_8.png" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you find this helpful&lt;/P&gt;&lt;P&gt;Neal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Jun 2020 17:25:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/843682#M163</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2020-06-28T17:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query Date in Model Builder with Inline Variable</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1082055#M164</link>
      <description>&lt;P&gt;Thanks - a simple solution to an annoying problem. Worked a treat.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 05:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1082055#M164</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2021-07-23T05:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Query Date in Model Builder with Inline Variable</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1123990#M165</link>
      <description>&lt;P&gt;This saved me some major headaches.&amp;nbsp; Thanks so much for sharing!!&lt;/P&gt;&lt;P&gt;Aaron Krusniak&lt;BR /&gt;Chicago Department of Public Health&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 19:44:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1123990#M165</guid>
      <dc:creator>aaronkrusniak</dc:creator>
      <dc:date>2021-12-08T19:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Query Date in Model Builder with Inline Variable</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1195052#M166</link>
      <description>&lt;P&gt;This did the trick.&amp;nbsp; Thanks for sharing.&amp;nbsp; Will come in handy many times over.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 18:36:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1195052#M166</guid>
      <dc:creator>BrendanFordDC</dc:creator>
      <dc:date>2022-07-22T18:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Query Date in Model Builder with Inline Variable</title>
      <link>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1268368#M167</link>
      <description>&lt;P&gt;Thanks you so much for this Neal, really made my morning!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 00:39:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/modelbuilder-questions/query-date-in-model-builder-with-inline-variable/m-p/1268368#M167</guid>
      <dc:creator>Psoralea</dc:creator>
      <dc:date>2023-03-16T00:39:52Z</dc:date>
    </item>
  </channel>
</rss>

