<?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: Help with Definition Query for Current Date minus 7 days in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503051#M28488</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gentlemen thank you for your responses.&amp;nbsp; Steve, your method hit the nail on the head! I am beyond excited to implement some changes today.&amp;nbsp; I will have to talk to my vendor about filtering at the view level since there are multiple analysts using that same view for different queries.&amp;nbsp; Either way, your solution is going to greatly improve our time savings.&amp;nbsp; Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paula F. Cutrone&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lead Crime Analyst&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Onondaga Crime Analysis Center&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Syracuse, NY&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 May 2011 11:11:54 GMT</pubDate>
    <dc:creator>PaulaCutrone1</dc:creator>
    <dc:date>2011-05-03T11:11:54Z</dc:date>
    <item>
      <title>Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503048#M28485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello community, I could really use some help!&amp;nbsp; Our Crime Analysis Center has recently transitioned over to using Arc Server and sde.&amp;nbsp; Our data is stored in SQL and we have a point feature class that is joined to the table through a view.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are trying to set up definition queries for different crime types to show the incidents that occurred over the past 7 days so we won't have to continually change the date range in the definition query.&amp;nbsp; I have seen in other posts to use CURRENT_DATE but I am not familiar with SQL language (not yet at least) and don't know how to structure the minus 7 days part.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a huge hurdle in our process and finding the answer would save us countless man hours a week.&amp;nbsp; We also prepare analysis based on the past 4 weeks and 6 weeks of data so you can see how challenging it would be to have to keep changing the date ranges by hand.&amp;nbsp; Thank you in advance for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Paula F. Cutrone&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lead Crime Analyst&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Onondaga Crime Analysis Center&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Syracuse, NY&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2011 23:11:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503048#M28485</guid>
      <dc:creator>PaulaCutrone1</dc:creator>
      <dc:date>2011-05-02T23:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503049#M28486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcSDE supports five different RDBMSes that use SQL, all of which have different syntax&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for referring to dates and date functions.&amp;nbsp; Even using just Microsoft SQL-Server, there&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;are multiple possible flavors (2005, 2008, 2008R2).&amp;nbsp; Dates can also be difficult due to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;variability of precision -- does a time reference to a day without hour imply midnight&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or noon, and in what timezone?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What you're looking for probably involves the SYSDATETIME() function and some variant&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;of DATEADD or DATEDIFF --&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where date_col &amp;gt; DATEADD(day,-7,SYSDATETIME())&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where DATEDIFF(day,date_col,SYSDATETIME()) &amp;lt; 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but that depends on the exact types involved.&amp;nbsp; This &lt;/SPAN&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms186724.aspx"&gt;documentation page&lt;/A&gt;&lt;SPAN&gt; is probably a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;good starting point, but you'll likely need to experiment, since different variants of the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;same expression are likely to give different performance, depending on how the index&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;interacts with the expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 00:12:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503049#M28486</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2011-05-03T00:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503050#M28487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Paula,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am actually doing something very similar to what you're doing, for traffic related incidents (drink driving, etc.).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are using SQL Server, you can use the GetDate() function in your definition query, something like: OccurrenceDate &amp;gt; GetDate() - 7&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or alternatively, you can set that filter in your view itself, so that you end up with a set of views in SQL server (e.g. last 7 days, las 30 days, etc.) and then you can join your point feature to the individual views without the need for a definition query. The advantage of setting the filter in the database itself is that is is easier to test and also to make sure that you're not mixing different locales (e.g. in our install ArcSDE stores dates as UTC).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, if you are using ArcSDE 10, you can use query layers to bring the views into your mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve Vidal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Solutions Architect, I-TAS Project&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Intelligent Traffic Policing Program&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Operations Support Command&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Queensland Police Services&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 00:28:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503050#M28487</guid>
      <dc:creator>SteveVidal</dc:creator>
      <dc:date>2011-05-03T00:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503051#M28488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gentlemen thank you for your responses.&amp;nbsp; Steve, your method hit the nail on the head! I am beyond excited to implement some changes today.&amp;nbsp; I will have to talk to my vendor about filtering at the view level since there are multiple analysts using that same view for different queries.&amp;nbsp; Either way, your solution is going to greatly improve our time savings.&amp;nbsp; Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paula F. Cutrone&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lead Crime Analyst&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Onondaga Crime Analysis Center&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Syracuse, NY&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2011 11:11:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503051#M28488</guid>
      <dc:creator>PaulaCutrone1</dc:creator>
      <dc:date>2011-05-03T11:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503052#M28489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can someone provide an example that will work with a Personal Geodatabase?&amp;nbsp; The above examples produce an error message when I use them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried this syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;... AND Date_Site_Mod &amp;gt; GETDATE() -3&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 13:13:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503052#M28489</guid>
      <dc:creator>DavidWheelock</dc:creator>
      <dc:date>2012-02-28T13:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Definition Query for Current Date minus 7 days</title>
      <link>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503053#M28490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Can someone provide an example that will work with a Personal Geodatabase?&amp;nbsp; The above examples produce an error message when I use them.&lt;BR /&gt;&lt;BR /&gt;I have tried this syntax:&lt;BR /&gt;... AND Date_Site_Mod &amp;gt; GETDATE() -3&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Google "&lt;/SPAN&gt;&lt;A href="http://office.microsoft.com/en-us/access-help/datediff-function-HA001228811.aspx"&gt;datediff function access&lt;/A&gt;&lt;SPAN&gt;"...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 15:41:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/help-with-definition-query-for-current-date-minus/m-p/503053#M28490</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2012-02-28T15:41:08Z</dc:date>
    </item>
  </channel>
</rss>

