<?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: Query FeatureLayer by date in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525592#M49018</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had some challenges with this recently.&amp;nbsp; For me, a good starting point was to use the layer properties dialog in &lt;/SPAN&gt;&lt;STRONG&gt;ArcMap&lt;/STRONG&gt;&lt;SPAN&gt; to build the definition query that I wanted.&amp;nbsp; Once I had the format that ArcMap expected (for the particular layer I was working with), I could begin playing around with rendering the definition query from the JS side.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, I was working against an Oracle, non-sde (native spatial type) feature class, and the definition query expected an Oracle specific date function: TO_DATE('yyyy-mm-dd hh:mm:ss','YYYY-MM-DD HH24:MI:SS').&amp;nbsp; I was unable to get the Oracle date function to work correctly, so I ended up casting the Oracle timestamp to a UNIX timestamp (milliseconds since 1/1/1970) and querying against that directly - this was easier b/c &lt;/SPAN&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;I didn't have to deal with any weird date functions&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;it just becomes a number comparison condition&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;Word of warning about JavaScript and dates.&amp;nbsp; Make sure you carefully look at the timestamp as I believe, at some level, JavaScript always stores timezone information into the date.&amp;nbsp; I ended up having to perform a UTC offset on some of the data I was processing to make the timestamps that I was getting from Oracle match up with dates I was rendering in JS code.&amp;nbsp; Probably a mistake somewhere on my part, but something to be aware of.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 May 2014 15:22:20 GMT</pubDate>
    <dc:creator>ChipHankley1</dc:creator>
    <dc:date>2014-05-07T15:22:20Z</dc:date>
    <item>
      <title>Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525589#M49015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can someone give me an example of how I would query a featurelayer by date?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a field in my featureservice named 'time'. The field type is: type: esriFieldTypeDate&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this documented anywhere what that field type expects? I've sent all kinds of different date formats including:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mm/dd/yyyy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;yyyy-mm-dd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;yyyy-mm-dd HH:MM:SS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unix_time_stamp (1399336752182)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm sure someone out there has queried features before or after a particular date... I'd just like to see an example as I can't find any API docs that show how this should be done.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 May 2014 23:40:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525589#M49015</guid>
      <dc:creator>JimWharton</dc:creator>
      <dc:date>2014-05-05T23:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525590#M49016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;where = "dateField &amp;gt; date'YYYY/MM/DD'"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AGS 10+&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 15:03:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525590#M49016</guid>
      <dc:creator>BenFousek</dc:creator>
      <dc:date>2014-05-06T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525591#M49017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From the ArcGIS Server REST API: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/rest/apiref/feature.html"&gt;feature&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;Note that date values are encoded as numbers. The number represents the number of milliseconds since epoch (January 1, 1970) in UTC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;query.where = "(time &amp;gt; " + fromDate.valueOf() + ") AND (time &amp;lt; " + toDate.valueOf() + ")";&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JS Date Object: &lt;/SPAN&gt;&lt;A href="http://www.w3schools.com/jsref/jsref_obj_date.asp"&gt;link&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 15:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525591#M49017</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2014-05-06T15:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525592#M49018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had some challenges with this recently.&amp;nbsp; For me, a good starting point was to use the layer properties dialog in &lt;/SPAN&gt;&lt;STRONG&gt;ArcMap&lt;/STRONG&gt;&lt;SPAN&gt; to build the definition query that I wanted.&amp;nbsp; Once I had the format that ArcMap expected (for the particular layer I was working with), I could begin playing around with rendering the definition query from the JS side.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, I was working against an Oracle, non-sde (native spatial type) feature class, and the definition query expected an Oracle specific date function: TO_DATE('yyyy-mm-dd hh:mm:ss','YYYY-MM-DD HH24:MI:SS').&amp;nbsp; I was unable to get the Oracle date function to work correctly, so I ended up casting the Oracle timestamp to a UNIX timestamp (milliseconds since 1/1/1970) and querying against that directly - this was easier b/c &lt;/SPAN&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;I didn't have to deal with any weird date functions&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;it just becomes a number comparison condition&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;Word of warning about JavaScript and dates.&amp;nbsp; Make sure you carefully look at the timestamp as I believe, at some level, JavaScript always stores timezone information into the date.&amp;nbsp; I ended up having to perform a UTC offset on some of the data I was processing to make the timestamps that I was getting from Oracle match up with dates I was rendering in JS code.&amp;nbsp; Probably a mistake somewhere on my part, but something to be aware of.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2014 15:22:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525592#M49018</guid>
      <dc:creator>ChipHankley1</dc:creator>
      <dc:date>2014-05-07T15:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525593#M49019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I guess I must be using the wrong type of date field or something. That doesn't work for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my service definition: &lt;/SPAN&gt;&lt;A href="https://services1.arcgis.com/BqQ60RORKMjmx3jf/ArcGIS/rest/services/Photos_Template/FeatureServer/0"&gt;https://services1.arcgis.com/BqQ60RORKMjmx3jf/ArcGIS/rest/services/Photos_Template/FeatureServer/0&lt;/A&gt;&lt;SPAN&gt; (I don't think&amp;nbsp; token is required)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 20:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525593#M49019</guid>
      <dc:creator>JimWharton</dc:creator>
      <dc:date>2014-05-08T20:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525594#M49020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;are you sure that's the correct url?&amp;nbsp; The service seems to be empty.&amp;nbsp; When using 'where: 1=1' and 'returnCountOnly: true' parameters: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Request:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://services1.arcgis.com/BqQ60RORKMjmx3jf/ArcGIS/rest/services/Photos_Template/FeatureServer/0/query?where=1%3D1&amp;amp;returnCountOnly=true&amp;amp;f=json"&gt;https://services1.arcgis.com/BqQ60RORKMjmx3jf/ArcGIS/rest/services/Photos_Template/FeatureServer/0/query?where=1%3D1&amp;amp;returnCountOnly=true&amp;amp;f=json&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Result: { "count": 0}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 May 2014 15:53:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525594#M49020</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2014-05-09T15:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query FeatureLayer by date</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525595#M49021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The service has been regenerated, nothing exists there yet. The ESRI Date Type is the only date/time type that I can see.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, from all the responses here, a normal unix timestamp is what ArcGIS Online services expect as a param.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(The number of seconds from Jan 1, 1970) Is this correct?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 May 2014 21:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-featurelayer-by-date/m-p/525595#M49021</guid>
      <dc:creator>JimWharton</dc:creator>
      <dc:date>2014-05-11T21:07:17Z</dc:date>
    </item>
  </channel>
</rss>

