<?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: Data Definition to find rows from past 90 days in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418099#M23855</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure the tbl2_INS_Date a date field? Also if you need to be exact you should look at what date you are getting (i.e., UTC vs. Local).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are working against a sql database you may need to use DATEDIFF() in the WHERE statement of your Select (e.g., in Select by Attribute window)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATEDIFF(day, INS_DATE, GETDATE()) &amp;lt; 91&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works with ArcGIS Desktop 10.5.1 and SQL 2014 database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Dec 2017 00:40:16 GMT</pubDate>
    <dc:creator>RichardDaniels</dc:creator>
    <dc:date>2017-12-08T00:40:16Z</dc:date>
    <item>
      <title>Data Definition to find rows from past 90 days</title>
      <link>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418098#M23854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using ArcMap 10.5 with a table within our Enterprise SDE that has a join to a view (also in the SDE). This view has a date field that I would like to use to filter my data on. I need to find rows that were inspected in the past 90 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INS_DATE field properties:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="390228" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/390228_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;An sample of my data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE class="j-table jiveBorder" style="border: 1px solid #c6c6c6;" width="100%"&gt;&lt;THEAD&gt;&lt;TR style="background-color: #efefef; height: 25px;"&gt;&lt;TH style="height: 25px;"&gt;tbl1.ObjectID&lt;/TH&gt;&lt;TH style="height: 25px;"&gt;tbl1.AssetID&lt;/TH&gt;&lt;TH style="height: 25px;"&gt;tbl1.Shape()&lt;/TH&gt;&lt;TH style="height: 25px;"&gt;tbl2.AssetID&lt;/TH&gt;&lt;TH style="height: 25px;"&gt;tbl2.INS_DATE&lt;/TH&gt;&lt;/TR&gt;&lt;/THEAD&gt;&lt;TBODY&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px;"&gt;1&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10000&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10000&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;3/02/2016 11:34:52 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px;"&gt;2&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10001&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10000&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;29/11/2017 8:37:12 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR style="height: 25px;"&gt;&lt;TD style="height: 25px;"&gt;3&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10002&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;10000&lt;/TD&gt;&lt;TD style="height: 25px;"&gt;29/11/2017 1:45:23 PM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I want to limit my rows to ones that have an INS_DATE within the past 90 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been trying to use the below code (and about a dozen variables of it) all give a non-descriptive error:&lt;/P&gt;&lt;PRE class="line-numbers language-sql"&gt;&lt;CODE&gt;SDE_SPATIAL&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GISADMIN&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt;AUDITS_LATEST_RECORD&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;INS_DATE &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;GetDate&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; &lt;SPAN class="number token"&gt;90&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;P&gt;&lt;IMG __jive_id="390229" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/390229_pastedImage_2.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there another way I should be approaching this one?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/NathanDuncan"&gt;NathanDuncan&lt;/A&gt;‌ FYI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Dec 2017 23:19:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418098#M23854</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2017-12-07T23:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data Definition to find rows from past 90 days</title>
      <link>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418099#M23855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure the tbl2_INS_Date a date field? Also if you need to be exact you should look at what date you are getting (i.e., UTC vs. Local).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are working against a sql database you may need to use DATEDIFF() in the WHERE statement of your Select (e.g., in Select by Attribute window)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATEDIFF(day, INS_DATE, GETDATE()) &amp;lt; 91&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works with ArcGIS Desktop 10.5.1 and SQL 2014 database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Dec 2017 00:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418099#M23855</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2017-12-08T00:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data Definition to find rows from past 90 days</title>
      <link>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418100#M23856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I included a screenshot of my INS_DATE field, i do see it is a DATE type, is there any way it may not be storing dates?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't need to be exact with the 90 days, if I am within 24hr each side of that it will not matter for this particular job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See below screenshot from when I tried using the DATEDIFF method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/390241_pastedImage_1.png" style="width: 620px; height: 487px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/390248_pastedImage_2.png" style="width: 620px; height: 483px;" /&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;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Dec 2017 00:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418100#M23856</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2017-12-08T00:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Data Definition to find rows from past 90 days</title>
      <link>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418101#M23857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;im not sure if it matters, but I'm thinking it could, the AUDITS_LATEST_RECORD is a joined view. It is joined to the ALBURYTREES via this setup:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;FROM&lt;/SPAN&gt; 
ALBURYTREES &lt;SPAN class="keyword token"&gt;LEFT&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;JOIN&lt;/SPAN&gt;
AUDITS_LATEST_RECORD &lt;SPAN class="keyword token"&gt;ON&lt;/SPAN&gt; ALBURYTREES&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ASSET_ID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; AUDITS_LATEST_RECORD&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ASSET_ID‍‍‍&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;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/390503_pastedImage_1.png" style="width: 620px; height: 488px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/390504_pastedImage_2.png" style="width: 620px; height: 488px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also just looking at the INS_DATE field, I have confirmed it is of type 'DATE', but you will note the formatting within switches between date only, to datetime.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way I can cast everything to be a date first, and then find rows where date is from last 90 days?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; I cannot modify the actual data to do this, it must be done in the Definition Query...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/390505_pastedImage_3.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/data-definition-to-find-rows-from-past-90-days/m-p/418101#M23857</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2021-12-11T18:54:42Z</dc:date>
    </item>
  </channel>
</rss>

