<?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 SQL Query to Select All Dates Starting Today and Two Years Prior in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/sql-query-to-select-all-dates-starting-today-and/m-p/819789#M3663</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! I am trying to create an SQL query through the Select By Attribute window on a date field that will select the &lt;STRONG&gt;current date&lt;/STRONG&gt; and &lt;STRONG&gt;everything two years prior.&lt;/STRONG&gt;&amp;nbsp;I can't seem to find anything online where this has been completed successfully. I am using ArcMap 10.7 and trying to do the Select By Attribute on a Date field which I manually enter the dates into. The reason I want an SQL expression that will grab the Current Date and everything prior for two years is because this expression will then be incorporated into a nightly run model so the date is consecutively changing as time goes on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing that I think is important to mention is that I am not entering new dates into my database daily. With this being said then, can I use CURRENT_DATE&amp;nbsp; in my expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: I wrote this post on 08/14/2019. So the expression I am looking for, when&amp;nbsp;run &lt;STRONG&gt;today&lt;/STRONG&gt; would select all dates between &lt;STRONG&gt;08/14/2019&lt;/STRONG&gt; and &lt;STRONG&gt;08/14/2017&lt;/STRONG&gt; and then &lt;STRONG&gt;tomorrow&lt;/STRONG&gt; the expression would select all dates between &lt;STRONG&gt;08/15/2019&lt;/STRONG&gt; and &lt;STRONG&gt;08/15/2017&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also my selection field is called: LegalEnd_Da&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried the following expression, which verifies successfully yet nothing in my attribute table is actually selected:&lt;/P&gt;&lt;P&gt;"LegalEndDa" &amp;lt;= (CURRENT_DATE -750) AND "LegalEndDa" &amp;gt;= CURRENT_DATE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance and I hope I have clarified my end goal clearly enough.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siona&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Aug 2019 15:26:11 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2019-08-14T15:26:11Z</dc:date>
    <item>
      <title>SQL Query to Select All Dates Starting Today and Two Years Prior</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-query-to-select-all-dates-starting-today-and/m-p/819789#M3663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello! I am trying to create an SQL query through the Select By Attribute window on a date field that will select the &lt;STRONG&gt;current date&lt;/STRONG&gt; and &lt;STRONG&gt;everything two years prior.&lt;/STRONG&gt;&amp;nbsp;I can't seem to find anything online where this has been completed successfully. I am using ArcMap 10.7 and trying to do the Select By Attribute on a Date field which I manually enter the dates into. The reason I want an SQL expression that will grab the Current Date and everything prior for two years is because this expression will then be incorporated into a nightly run model so the date is consecutively changing as time goes on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing that I think is important to mention is that I am not entering new dates into my database daily. With this being said then, can I use CURRENT_DATE&amp;nbsp; in my expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: I wrote this post on 08/14/2019. So the expression I am looking for, when&amp;nbsp;run &lt;STRONG&gt;today&lt;/STRONG&gt; would select all dates between &lt;STRONG&gt;08/14/2019&lt;/STRONG&gt; and &lt;STRONG&gt;08/14/2017&lt;/STRONG&gt; and then &lt;STRONG&gt;tomorrow&lt;/STRONG&gt; the expression would select all dates between &lt;STRONG&gt;08/15/2019&lt;/STRONG&gt; and &lt;STRONG&gt;08/15/2017&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also my selection field is called: LegalEnd_Da&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried the following expression, which verifies successfully yet nothing in my attribute table is actually selected:&lt;/P&gt;&lt;P&gt;"LegalEndDa" &amp;lt;= (CURRENT_DATE -750) AND "LegalEndDa" &amp;gt;= CURRENT_DATE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance and I hope I have clarified my end goal clearly enough.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siona&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2019 15:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-query-to-select-all-dates-starting-today-and/m-p/819789#M3663</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-08-14T15:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Query to Select All Dates Starting Today and Two Years Prior</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-query-to-select-all-dates-starting-today-and/m-p/819790#M3664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After writing this post and staring at my expression for sometime, I realized I had my Less Than/Greater Than symbols backwards. The expression worked like a charm, in case anyone is out there trying to do the same thing!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Aug 2019 16:26:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-query-to-select-all-dates-starting-today-and/m-p/819790#M3664</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-08-14T16:26:39Z</dc:date>
    </item>
  </channel>
</rss>

