<?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: How to set a defintionExpression in JS in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576707#M53845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes i have a the startField set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const layer = new FeatureLayer({&lt;BR /&gt; url: "https://gis.appleton.org/pubserver/rest/services/Hosted/EnvisionAppleton/FeatureServer/0",&lt;BR /&gt; copyright: "City of Appleton",&lt;BR /&gt; title: "Envision Appleton",&lt;BR /&gt; // set the CSVLayer's timeInfo based on the date field&lt;BR /&gt; timeInfo: {&lt;BR /&gt; startField: "project_date", // name of the date field&lt;BR /&gt; interval: {&lt;BR /&gt; // set time interval to one day&lt;BR /&gt; unit: "days",&lt;BR /&gt; value: 1&lt;BR /&gt; }&lt;BR /&gt; },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a copy of my code if you want to look at it instead of me sending snippets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://codepen.io/handerson1/pen/gOOLYMw?editors=1001" title="https://codepen.io/handerson1/pen/gOOLYMw?editors=1001"&gt;https://codepen.io/handerson1/pen/gOOLYMw?editors=1001&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Oct 2019 15:19:40 GMT</pubDate>
    <dc:creator>HeathAnderson</dc:creator>
    <dc:date>2019-10-21T15:19:40Z</dc:date>
    <item>
      <title>How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576703#M53841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am struggling getting my definition expression to work with a time aware field.&amp;nbsp; I believe I have narrowed down the problem to the layer.definitionExpression.&amp;nbsp; I have successfully made a definition expression for a text field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;layer.definitionExpression = "project_type = 'SUP'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I have been unsuccessful in writing one for a time aware field.&amp;nbsp; Should I be using the field name {project_date} or 'time'?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;timeSlider&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;watch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"timeExtent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;// only show earthquakes happened up until the end of&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;// timeSlider's current time extent.&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;//defExp = layer.definitionExpression = "time = " + timeSlider.timeExtent.end.getTime();&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;//defExp = layer.definitionExpression = "project_type = 'SUP'";&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;//defExp = layer.definitionExpression = "time=1571202000000";&lt;/SPAN&gt;
          defExp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;definitionExpression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"time="&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1571202000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
          defExp2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;definitionExpression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"project_date="&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1571202000000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
          &lt;SPAN class="comment token"&gt;//checks definitonExpression &lt;/SPAN&gt;
          console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;defExp&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
          console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;defExp2&lt;SPAN class="punctuation token"&gt;)&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;/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;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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that the epoch time&amp;nbsp;1571202000000 exists in my dataset because I can query it in the rest end point and the query yields 2 results, however that doesn't seem directly translate to JS.&amp;nbsp; Can some one please help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="462231" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/462231_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="462232" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/462232_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576703#M53841</guid>
      <dc:creator>HeathAnderson</dc:creator>
      <dc:date>2021-12-12T00:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576704#M53842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heath,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I normally query dates in JS this way:&lt;/P&gt;&lt;P&gt;project_date = TIMESTAMP '2019-10-18 16:30:00'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Oct 2019 21:24:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576704#M53842</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2019-10-18T21:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576705#M53843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;Thank you for your quick reply.&amp;nbsp; That code didn't seem to work either&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;defExp2 = layer.definitionExpression = "project_date = TIMESTAMP '2019-10-18 16:30:00'";&lt;/P&gt;&lt;P&gt;defExp2 = layer.definitionExpression = "project_date = TIMESTAMP 2019-10-18 16:30:00";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had thought about using the TIMESTAMP earlier in my vetting process but seeing as how the database stores it in epoch as well as the timeslider querying in epoch I thought I though I would stick with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either way, neither the TIMESTAMP or epoch code seems to be working with the fieldname or "time" designation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Heath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Oct 2019 21:36:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576705#M53843</guid>
      <dc:creator>HeathAnderson</dc:creator>
      <dc:date>2019-10-18T21:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576706#M53844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heath,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;It seems like you are wanting to set a features time extent (ie. begin time and end time) if so then look at the layer timeinfo property:&lt;/P&gt;&lt;P&gt;&lt;A class="link-bare" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#timeInfo" title="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#timeInfo"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#timeInfo&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Oct 2019 12:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576706#M53844</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2019-10-19T12:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576707#M53845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes i have a the startField set&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const layer = new FeatureLayer({&lt;BR /&gt; url: "https://gis.appleton.org/pubserver/rest/services/Hosted/EnvisionAppleton/FeatureServer/0",&lt;BR /&gt; copyright: "City of Appleton",&lt;BR /&gt; title: "Envision Appleton",&lt;BR /&gt; // set the CSVLayer's timeInfo based on the date field&lt;BR /&gt; timeInfo: {&lt;BR /&gt; startField: "project_date", // name of the date field&lt;BR /&gt; interval: {&lt;BR /&gt; // set time interval to one day&lt;BR /&gt; unit: "days",&lt;BR /&gt; value: 1&lt;BR /&gt; }&lt;BR /&gt; },&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a copy of my code if you want to look at it instead of me sending snippets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://codepen.io/handerson1/pen/gOOLYMw?editors=1001" title="https://codepen.io/handerson1/pen/gOOLYMw?editors=1001"&gt;https://codepen.io/handerson1/pen/gOOLYMw?editors=1001&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2019 15:19:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576707#M53845</guid>
      <dc:creator>HeathAnderson</dc:creator>
      <dc:date>2019-10-21T15:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576708#M53846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3101" target="_blank"&gt;Robert Scheitlin, GISP&lt;/A&gt;‌, you should use standard sql query to query dates. When you are setting FeatureLayer.definitionExpression you are making &lt;A href="https://developers.arcgis.com/rest/services-reference/query-feature-service-layer-.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Rest API query&lt;/A&gt; call (search for where).&amp;nbsp; &lt;A href="https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/" rel="nofollow noopener noreferrer" target="_blank"&gt;This blog&lt;/A&gt; talks about how to query date fields.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With all of the above said, you should not have to set the layer's definitionExpression whenever the timeSlider's timeExtent changes. You can set the TimeSlider.view property and&amp;nbsp;all&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&amp;nbsp;time-aware layers will automatically update to conform to the view's timeExtent.&lt;/SPAN&gt;&amp;nbsp;Please look through the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-TimeSlider.html" rel="nofollow noopener noreferrer" target="_blank"&gt;TimeSlider SDK&lt;/A&gt; doc (see Update the view's doc section).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have updated your app to do that and here is the &lt;A href="https://codepen.io/U_B_U/pen/LYYxRgJ?editors=1000" rel="nofollow noopener noreferrer" target="_blank"&gt;link&lt;/A&gt;. I noticed that your service's time interval units is set to unknown. So in the test app, I am setting TimeSlider's stop.interval to one day as shown below:&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;const&lt;/SPAN&gt; timeSlider &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;TimeSlider&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  container&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"timeSlider"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    playRate&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;300&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    view&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; view&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    stops&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      interval&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        value&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        unit&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"days"&lt;/SPAN&gt;
      &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&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;/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;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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:49:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576708#M53846</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-12-12T00:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a defintionExpression in JS</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576709#M53847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Undral,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the detail explanation.&amp;nbsp; That cleared it up for me&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Heath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2019 18:11:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-a-defintionexpression-in-js/m-p/576709#M53847</guid>
      <dc:creator>HeathAnderson</dc:creator>
      <dc:date>2019-10-21T18:11:42Z</dc:date>
    </item>
  </channel>
</rss>

