<?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: Definition Query with dates in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074670#M42801</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (NOW() - interval '6 months')&lt;/PRE&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;It looks like you can't use those functions in Pro, even if the DB itself would in a query. Try this instead:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (CURRENT_DATE - 182)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jul 2021 13:20:22 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-07-01T13:20:22Z</dc:date>
    <item>
      <title>Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074642#M42797</link>
      <description>&lt;P&gt;HI,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really hope someone can help me out with this. I have a definition query defined on a feature class coming from an Oracle SDE where a date field is queried to return values within 6 months of the current date (see below)&lt;/P&gt;&lt;P&gt;RELDATE_DATE &amp;gt; ADD_MONTHS(TO_DATE(SYSDATE),-6&lt;/P&gt;&lt;P&gt;We are in the process of migrating to a PostgreSQL SDE and with the same feature class the query no longer works or is verified ( returns an error)&lt;/P&gt;&lt;P&gt;What should my new definition query look like?&lt;/P&gt;&lt;P&gt;The feature class filed being queried is&amp;nbsp;&lt;STRONG&gt;RELDATE_DATE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Gregor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:35:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074642#M42797</guid>
      <dc:creator>GregorCalderwood1</dc:creator>
      <dc:date>2021-07-01T12:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074670#M42801</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (NOW() - interval '6 months')&lt;/PRE&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;It looks like you can't use those functions in Pro, even if the DB itself would in a query. Try this instead:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (CURRENT_DATE - 182)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 13:20:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074670#M42801</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-01T13:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074687#M42803</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;Thanks for the response - the&amp;nbsp;&lt;STRONG&gt;RELDATE_DATE &amp;gt; (CURRENT_DATE -182)&lt;/STRONG&gt; works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 13:43:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1074687#M42803</guid>
      <dc:creator>GregorCalderwood1</dc:creator>
      <dc:date>2021-07-01T13:43:14Z</dc:date>
    </item>
    <item>
      <title>maybe this will help?   Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1075191#M42862</link>
      <description>Classification: UNCLASSIFIED&lt;BR /&gt;======================================================&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Gregor,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try the following found in&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/1888544/how-to-select-records-from-last-24-hours-using-sql" target="_blank"&gt;https://stackoverflow.com/questions/1888544/how-to-select-records-from-last-24-hours-using-sql&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In MySQL:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= NOW() - INTERVAL 1 DAY&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In SQL Server:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= DATEADD(day, -1, GETDATE())&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In Oracle:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= SYSDATE - 1&lt;BR /&gt;&lt;BR /&gt;In PostgreSQL:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= NOW() - '1 day'::INTERVAL&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In Redshift:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= GETDATE() - '1 day'::INTERVAL&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In SQLite:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= datetime('now','-1 day')&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In MS Access:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SELECT *&lt;BR /&gt;&lt;BR /&gt;FROM mytable&lt;BR /&gt;&lt;BR /&gt;WHERE record_date &amp;gt;= (Now - 1)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;select * from table where date_field &amp;gt; (now() - interval '24 hour');&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Jul 2021 15:37:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1075191#M42862</guid>
      <dc:creator>Prab</dc:creator>
      <dc:date>2021-07-02T15:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1262448#M66017</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 3 layers all pointing to one data source with different definition queries&amp;nbsp; by dates. However, someone pointed out that this can be done better as we have to change the year date every year and they said we can write a query that doesnt need changing every year, but they didnt have time to tell me what the query would be.... could anyone help?&lt;/P&gt;&lt;P&gt;Current year is anything post 1st April 2022&lt;/P&gt;&lt;P&gt;Previous year is anything between 1st April 2021 and 31st march 2022&lt;/P&gt;&lt;P&gt;Old data is 31st March 2021 and before&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the queries we currently have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Current -&lt;/STRONG&gt; DATE_LOGGED &amp;gt;= '2022-04-01 00:00:01'&lt;/P&gt;&lt;P&gt;Previous - DATE_LOGGED &amp;gt;= '2021-04-01 00:00:00' AND DATE_LOGGED &amp;lt;= '2022-03-31 00:00:00'&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Old -&lt;/STRONG&gt; DATE_LOGGED &amp;lt;= '2021-03-31 00:00:00'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I write the query so that I dont have to change the year in the query every 1st April?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 14:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1262448#M66017</guid>
      <dc:creator>LauraBoagey1</dc:creator>
      <dc:date>2023-02-28T14:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1413572#M82214</link>
      <description>&lt;P&gt;I have a similar issue with a definition query. This&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (CURRENT_DATE - 182)&lt;/PRE&gt;&lt;P&gt;works when it is not combined with other conditions. The moment I add others, it throws an invalid syntax error. Here is my expression:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(CLASS = 'first' Or CLASS = 'second' Or CLASS = 'third' Or CLASS = 'fourth' Or CLASS = 'fifth' Or CLASS = 'sixth' Or CLASS = 'seventh' Or CLASS = 'eighth') And EQUIP = 'X'&lt;/STRONG&gt; And Date_Created &amp;gt; (CURRENT_DATE - 182)&lt;/P&gt;&lt;P&gt;Basically the bolded part works, but when I add the date filter, I get an error. (I am in Pro 3.2.1, to clarify).&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (NOW() - interval '6 months')&lt;/PRE&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;It looks like you can't use those functions in Pro, even if the DB itself would in a query. Try this instead:&lt;/P&gt;&lt;PRE&gt;RELDATE_DATE &amp;gt; (CURRENT_DATE - 182)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 16:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1413572#M82214</guid>
      <dc:creator>AlinaTarmu_SCGIS</dc:creator>
      <dc:date>2024-04-22T16:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Definition Query with dates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1676446#M101079</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I know this is an old post, but I believe there is a way to do this now in Arc Pro Definition Query with SQL&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EXTRACT(YEAR FROM "Date_Field") = EXTRACT(YEAR FROM CURRENT_DATE - 365)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This will allow someone to have way to auto filter years in a date field by the current date year +- however many days. This might be helpful to others rather than hard coding dates in the definition queries if the map is used year over year on a living data set.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dynamic SQL Date Query.jpg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/146440i8243923F40E0C5A3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dynamic SQL Date Query.jpg" alt="Dynamic SQL Date Query.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jan 2026 18:51:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/definition-query-with-dates/m-p/1676446#M101079</guid>
      <dc:creator>Andrew_McLellan</dc:creator>
      <dc:date>2026-01-07T18:51:39Z</dc:date>
    </item>
  </channel>
</rss>

