<?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 select and delete records older than 3 years in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1035666#M60341</link>
    <description>&lt;P&gt;We are attempting to maintain a dataset to include records only for the past 3 years.&amp;nbsp; New records are appended daily (via other scripted geoprocessing).&lt;/P&gt;&lt;P&gt;The table is in Enterprise SQL, and contains both varchar date (dd/mm/yyyy) and datetime (yyyy-mm-dd hh:mm:ss:ms) fields.&lt;/P&gt;&lt;P&gt;How do I select records that are 3 years older than yesterday (for deletion)?&amp;nbsp; I thought I was going down the correct path with this in SQL but I'm not getting far:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DateTimeField &amp;lt; DATEADD(yy, -3, CONVERT(datetime, CONVERT(varchar, GETDATE(), 101)))&lt;/P&gt;&lt;P&gt;I need selections to the day, not the datetime (e.g. On March 11, the new records from March 10 are appended, and anything more than 3 years older than March 10 are deleted.&amp;nbsp; It's to the full date, not the actual time of day when the script is run.)&amp;nbsp; This selection will be used within a scheduled .py daily.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 20:33:21 GMT</pubDate>
    <dc:creator>JustinWolff</dc:creator>
    <dc:date>2021-03-11T20:33:21Z</dc:date>
    <item>
      <title>select and delete records older than 3 years</title>
      <link>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1035666#M60341</link>
      <description>&lt;P&gt;We are attempting to maintain a dataset to include records only for the past 3 years.&amp;nbsp; New records are appended daily (via other scripted geoprocessing).&lt;/P&gt;&lt;P&gt;The table is in Enterprise SQL, and contains both varchar date (dd/mm/yyyy) and datetime (yyyy-mm-dd hh:mm:ss:ms) fields.&lt;/P&gt;&lt;P&gt;How do I select records that are 3 years older than yesterday (for deletion)?&amp;nbsp; I thought I was going down the correct path with this in SQL but I'm not getting far:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DateTimeField &amp;lt; DATEADD(yy, -3, CONVERT(datetime, CONVERT(varchar, GETDATE(), 101)))&lt;/P&gt;&lt;P&gt;I need selections to the day, not the datetime (e.g. On March 11, the new records from March 10 are appended, and anything more than 3 years older than March 10 are deleted.&amp;nbsp; It's to the full date, not the actual time of day when the script is run.)&amp;nbsp; This selection will be used within a scheduled .py daily.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Justin&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 20:33:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1035666#M60341</guid>
      <dc:creator>JustinWolff</dc:creator>
      <dc:date>2021-03-11T20:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: select and delete records older than 3 years</title>
      <link>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1035674#M60342</link>
      <description>&lt;P&gt;We use something like this where the days can be adjusted based on need for an extraction.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;days = 20
"last_edited_date &amp;gt;= (CURRENT_Date-" + str(days) + ")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 20:41:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1035674#M60342</guid>
      <dc:creator>Kara_Shindle</dc:creator>
      <dc:date>2021-03-11T20:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: select and delete records older than 3 years</title>
      <link>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1040822#M60572</link>
      <description>&lt;P&gt;Thanks Kara.&amp;nbsp; We're actually redesigning this project now.&amp;nbsp; I'm not sure if your suggestion would account for leap year days, etc.&amp;nbsp; Regardless, we're moving on for now but thanks again.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 20:35:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-and-delete-records-older-than-3-years/m-p/1040822#M60572</guid>
      <dc:creator>JustinWolff</dc:creator>
      <dc:date>2021-03-25T20:35:45Z</dc:date>
    </item>
  </channel>
</rss>

