<?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: Arcade FeatureSets and Date Fields: What's Going On? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1148136#M44609</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;There is something additional you need to do in order to create a valid featureset containing dates. The date has to be translated to a UNIX timestamp.&amp;nbsp; In the post below you can see an example:&amp;nbsp;&lt;A href="https://community.esri.com/t5/developers-questions/arcade-dictionary-to-featureset/td-p/1047117" target="_blank"&gt;https://community.esri.com/t5/developers-questions/arcade-dictionary-to-featureset/td-p/1047117&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Feb 2022 19:46:23 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2022-02-25T19:46:23Z</dc:date>
    <item>
      <title>Arcade FeatureSets and Date Fields: What's Going On?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1147785#M44599</link>
      <description>&lt;P&gt;When creating a FeatureSet from a dictionary, as in Data Expressions in Dashboards, I &lt;EM&gt;cannot &lt;/EM&gt;add a date to a date field.&lt;/P&gt;&lt;P&gt;In the simplest example, here's a single-feature set with a single field, which &lt;EM&gt;ought &lt;/EM&gt;to have the current date/time in it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs_dict = {
    fields: [{name: 'some_date', type: 'esriFieldTypeDate'}],
    geometryType: '',
    features: [
        {attributes: {some_date: Now()}}    
    ]
}

return FeatureSet(Text(fs_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this returns an empty set.&lt;/P&gt;&lt;P&gt;Casting the date as a &lt;STRONG&gt;number&lt;/STRONG&gt;, however, seems to work. Replace line 5 with the following:&lt;/P&gt;&lt;PRE&gt;{attributes: {some_date: Number(Now())}}&lt;/PRE&gt;&lt;P&gt;And it returns my feature!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1645742761727.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/34937i7EC96655AF6A3505/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1645742761727.png" alt="jcarlson_0-1645742761727.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I thought perhaps this was due to a difference in how the text-encoded datetime was being read. Leaving it as the datetime gives me &lt;STRONG&gt;2022-02-24T22:48:57.371Z&lt;/STRONG&gt;, whereas the number returns &lt;STRONG&gt;1645742863932&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;But cast either of those as a date, and it reads them both in just fine:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_1-1645743022565.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/34939iA3F30275A7AB0358/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_1-1645743022565.png" alt="jcarlson_1-1645743022565.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So what's going on in the &lt;STRONG&gt;FeatureSet&lt;/STRONG&gt; function? Why can it not handle text dates?&lt;/P&gt;&lt;P&gt;To add another layer to this, I can't even take a feature from one set and pass it to another without losing the rows with dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs_dict = {
    fields: [{name: 'some_date', type: 'esriFieldTypeDate'}],
    geometryType: '',
    features: [
        {attributes: {some_date: Now()}},
        {attributes: {some_date: Null}}
    ]
}

var fs = FeatureSet(Text(fs_dict))

var second_dict = {
    fields: [{name: 'some_date', type: 'esriFieldTypeDate'}],
    geometryType: '',
    features: []
}

// Copy features from fs to dict
for (var f in fs){
    Push(second_dict['features'], f)
}

return FeatureSet(Text(second_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Returns a one-row set with the null value, but not the Now.&lt;/P&gt;&lt;P&gt;The only way to pass features between sets is to cast them as a Number, but I can only do &lt;EM&gt;that &lt;/EM&gt;by explicitly stating each attribute, rather than just passing the entire feature.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 22:59:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1147785#M44599</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-24T22:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade FeatureSets and Date Fields: What's Going On?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1148136#M44609</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;There is something additional you need to do in order to create a valid featureset containing dates. The date has to be translated to a UNIX timestamp.&amp;nbsp; In the post below you can see an example:&amp;nbsp;&lt;A href="https://community.esri.com/t5/developers-questions/arcade-dictionary-to-featureset/td-p/1047117" target="_blank"&gt;https://community.esri.com/t5/developers-questions/arcade-dictionary-to-featureset/td-p/1047117&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 19:46:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1148136#M44609</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2022-02-25T19:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade FeatureSets and Date Fields: What's Going On?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1299931#M52865</link>
      <description>&lt;P&gt;With this week's update to Arcade and ArcGIS Dashboards, date fields in feature set constructors now just work. You no longer have to wrap dates with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Number()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;if you pass the &lt;EM&gt;dictionary&lt;/EM&gt; into the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;FeatureSet()&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function (which as of this release accepts a dictionary as opposed to only text based JSON).&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(Text(dict))&lt;/PRE&gt;&lt;P&gt;Do this:&lt;/P&gt;&lt;PRE&gt;return FeatureSet(dict)&lt;/PRE&gt;&lt;P&gt;Learn more in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/arcgis-dashboards-blog/dashboard-data-expressions-what-has-changed-june/ba-p/1298782" target="_blank" rel="noopener"&gt;this blog post&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;NOTE: For Enterprise users, this update is targeted for 11.2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 19:24:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-featuresets-and-date-fields-what-s-going-on/m-p/1299931#M52865</guid>
      <dc:creator>DavidNyenhuis1</dc:creator>
      <dc:date>2023-06-15T19:24:55Z</dc:date>
    </item>
  </channel>
</rss>

