<?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: ArcGIS Arcade DateDiff  in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788292#M66646</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using ArcGIS Online, FeatureSetByName is available. However, it is not available for every for every "profile". You can use these functions in pop-up window and for fields calculations, but it will not be available for the symbology. However, you can perform a field calculation and symbolize on the new field (this will not yield a dynamic result).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you can share some screenshot and explain a little more what you are trying to achieve?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Dec 2018 16:24:41 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2018-12-23T16:24:41Z</dc:date>
    <item>
      <title>ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788288#M66642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arcade expression in Web Map that can select the most recent date and calculate DateDiff. I have inspection data for the same site with multiple years (ex. 2014, 2015, 2016). I want to calculate (or only show) DateDiff between Date.Now() and - 2016). Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2018 22:36:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788288#M66642</guid>
      <dc:creator>MyriamWright</dc:creator>
      <dc:date>2018-12-20T22:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788289#M66643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure if I understand this correctly, but you have inspection locations multiple inspections (/2014, 2015 and 2016) for those locations. You want to calculate the time that has elapsed for each location inspection since the last inspection for that location?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is the case, this has become possible with the last update of AGOL&amp;nbsp;on December, 5th.If you want to show this&amp;nbsp;elapsed time since in the pop-up of the inspection locations, you can do something like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Access the table with the inspection history using &lt;STRONG&gt;FeatureSetByName&lt;/STRONG&gt; (using $map or $datastore to access the table)&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Filter&lt;/STRONG&gt; the inspection history table using the ID of the current inspection location (I assume your table has this information)&lt;/LI&gt;&lt;LI&gt;Use&amp;nbsp;&lt;STRONG&gt;Max&lt;/STRONG&gt;(tbl, DateFieldName) to get the maximum inspection date for that location&lt;/LI&gt;&lt;LI&gt;Use &lt;STRONG&gt;DateDiff&lt;/STRONG&gt; to calculate the elapsed time since the last inspection&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2018 18:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788289#M66643</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-12-21T18:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788290#M66644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks you for replying!&lt;/P&gt;&lt;P&gt;So, I used the following script modified with my field name from the developer.arcgis.com. It does calculate the DateDiff, but if I have more than one dates over the years, it calculates it for every single year. I am only looking for the last time an inspection was done. I am using ArcGIS online with data from a feature service. I am really new to Arcade and programming.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var startDate = $feature.StartDate;&lt;BR /&gt;var endDate = Now()&lt;BR /&gt;var retAge = null;&lt;BR /&gt; &lt;BR /&gt; if (startDate != null &amp;amp;&amp;amp; endDate != null) {&lt;BR /&gt; startDate = Date(startDate);&lt;BR /&gt; endDate = Date(endDate);&lt;BR /&gt; retAge = DateDiff(endDate, startDate, "years");&lt;BR /&gt; }&lt;BR /&gt;return retAge;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2018 19:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788290#M66644</guid>
      <dc:creator>MyriamWright</dc:creator>
      <dc:date>2018-12-21T19:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788291#M66645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;So, it looks like the&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG style="background-color: #ffffff; border: 0px; font-weight: bold;"&gt;FeatureSetByName&lt;/STRONG&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;&amp;nbsp;is not available in my ArcGIS online.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2018 20:16:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788291#M66645</guid>
      <dc:creator>MyriamWright</dc:creator>
      <dc:date>2018-12-21T20:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788292#M66646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using ArcGIS Online, FeatureSetByName is available. However, it is not available for every for every "profile". You can use these functions in pop-up window and for fields calculations, but it will not be available for the symbology. However, you can perform a field calculation and symbolize on the new field (this will not yield a dynamic result).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you can share some screenshot and explain a little more what you are trying to achieve?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Dec 2018 16:24:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788292#M66646</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2018-12-23T16:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788293#M66647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using Portal? If so, that's usually one or more versions behind the capabilities in ArcOnline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://enterprise.arcgis.com/en/portal/latest/use/about-versions.htm" title="http://enterprise.arcgis.com/en/portal/latest/use/about-versions.htm"&gt;About release versions—Portal for ArcGIS | ArcGIS Enterprise&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2018 18:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788293#M66647</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2018-12-26T18:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788294#M66648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not portal. I will check wit IT. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2018 19:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788294#M66648</guid>
      <dc:creator>MyriamWright</dc:creator>
      <dc:date>2018-12-26T19:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788295#M66649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would this expression work with a related table? We would be trying to track time since last submission. We have a feature service with a polygon of every state and a related table with all submissions an their dates. Could we use this FeatureSetByName function to call the related table, filter for the max date to find the most recent one for a particular state, and then use the DateDiff to compare against Now()?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 18:29:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788295#M66649</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-08T18:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788296#M66650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327406"&gt;Timothy Woodfield&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the pop-up you can certainly do this. We can have a look at this in more detail, but I would recommend to start a new question to avoid creating noise in this one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 19:48:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788296#M66650</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-09-08T19:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788297#M66651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi again Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had another question come up relating to this while working through the previous one. I was able to grab the expression from one of your other posts but am having a hard time getting the date in the format I need. I currently have this working but the date is being returned as "1599177600000":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// first read out the ID of the Feature1&lt;BR /&gt;var id = $feature.STATE_NAME;&lt;BR /&gt;// access the table Feature2&lt;BR /&gt;var tbl = FeatureSetByName($map, 'Registration Submissions');&lt;BR /&gt;// create a sql expression to query on ID&lt;BR /&gt;var sql = "STATE_NAME = '" + ID + "'";&lt;BR /&gt;// filter the table using the sql expression&lt;BR /&gt;var related_data = Filter(tbl, sql);&lt;BR /&gt;// initiate a variable to hold the result&lt;BR /&gt;var result = Max(tbl, 'SubmissionDate');&lt;BR /&gt;// return the result&lt;BR /&gt;return result;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to reformat using the date functions but am getting "NaN/Nan/Nan" as the string using this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// first read out the ID of the Feature1&lt;BR /&gt;var id = $feature.STATE_NAME;&lt;BR /&gt;// access the table Feature2&lt;BR /&gt;var tbl = FeatureSetByName($map, 'Registration Submissions');&lt;BR /&gt;// create a sql expression to query on ID&lt;BR /&gt;var sql = "STATE_NAME = '" + ID + "'";&lt;BR /&gt;// filter the table using the sql expression&lt;BR /&gt;var related_data = Filter(tbl, sql);&lt;BR /&gt;// initiate a variable to hold the result&lt;BR /&gt;var result = Max(tbl, 'SubmissionDate');&lt;BR /&gt;var relateddate = Month(result)+"/"+Day(result)+"/"+Year(result)&lt;BR /&gt;// return the result&lt;BR /&gt;return relateddate;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there another way I can get the date in a MM/DD/YYYY format from 'result'?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 20:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788297#M66651</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-08T20:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788298#M66652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327406" target="_blank"&gt;Timothy Woodfield&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the example below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// first read out the ID of the Feature1&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; id &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; $feature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;STATE_NAME&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// access the table Feature2&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Registration Submissions'&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;// create a sql expression to query on ID&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"STATE_NAME = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; ID &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// filter the table using the sql expression&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; related_data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Filter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// validate if you have any related records&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;related_data&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&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;// get the max date and format the result&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; maxdate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Max&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SubmissionDate'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; format &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MM/DD/Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Text&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxdate&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; format&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="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;// in case you don't have related records&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;// define what to return&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string 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;/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;On lines 13 and 14 the date is formatted using a defined format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would also recommend you to use the&amp;nbsp;FeatureSetByRelationshipName function in case the related records are related through a&amp;nbsp;RelationshipClass.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:00:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788298#M66652</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T09:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788299#M66653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for getting back so quick. I tried that out and got an error that says, "&lt;SPAN class="" style="color: #de2900; background-color: rgba(255, 255, 255, 0.8);"&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;unable to find a number expression in pattern: MM/DD/Y".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;I was able to set up another one that worked but it seems to be returning the wrong date. The related record has a date of 9/8/2020 but the expression is returning 8/8/2020. I tried it with a few others and it seemed to always be off by a month. This was the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;// first read out the ID of the Feature1&lt;BR /&gt;var id = $feature.STATE_NAME;&lt;BR /&gt;// access the table Feature2&lt;BR /&gt;var tbl = FeatureSetByName($map, 'Registration Submissions');&lt;BR /&gt;// create a sql expression to query on ID&lt;BR /&gt;var sql = "STATE_NAME = '" + ID + "'";&lt;BR /&gt;// filter the table using the sql expression&lt;BR /&gt;var related_data = Filter(tbl, sql);&lt;BR /&gt;// initiate a variable to hold the result&lt;BR /&gt;var result = Max(tbl, 'SubmissionDate');&lt;BR /&gt;var relateddate = Date(result)&lt;BR /&gt;var formatteddate= Month(relateddate)+"/"+Day(relateddate)+"/"+Year(relateddate)&lt;BR /&gt;// return the result&lt;BR /&gt;return formatteddate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;I'm guessing it's something to do with one of the Date functions. If I have it return 'result', it gives me the number&amp;nbsp;1599609600000. I checked this on epochconverter.com and it came back as 9/8/2020 at 9:40:47 PM GMT. I tried returning relateddate and that came back as 08 Sep 2020 08:00:00 pm so the date is correct at that point but gets skewed by the Month() function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;Any idea of what might be throwing it off by a month? Is there another way instead of the Month, Day, and Year function to format the date?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: rgba(255, 255, 255, 0.8);"&gt;Tim&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 21:49:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788299#M66653</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-08T21:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788300#M66654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/people/twoodfield_DawoodGIS" target="_blank"&gt;twoodfield_DawoodGIS&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess you don't have a date but an epoch in the field. Are you sure, the field is not a date but numeric?&lt;/P&gt;&lt;P&gt;You could do something like this (provide the epoch to the Date function to get a date and then format it):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; maxepoch &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1599609600000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; maxdate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxepoch&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; format &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MM/DD/Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Text&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxdate&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; format&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This returned:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;09/08/2020&lt;SPAN class="line-numbers-rows"&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 09:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788300#M66654</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T09:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788301#M66655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327406"&gt;Timothy Woodfield&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About the other question. Your month is 1 month off, since the Month function and Date function in Arcade (and JavaScript) expect you to specify the month as a value from 0 to 11 and not 1 to 12.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 22:01:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788301#M66655</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-09-08T22:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788302#M66656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What would be the best way to reformat the months to go from 0-11 and not 1-12? Is that something I need to set in ArcMap or Pro before publishing the feature service?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 22:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788302#M66656</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-08T22:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788303#M66657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/people/twoodfield_DawoodGIS" target="_blank"&gt;twoodfield_DawoodGIS&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would probably combine the last two examples and do this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// first read out the ID of the Feature1&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; id &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; $feature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;STATE_NAME&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// access the table Feature2&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; tbl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;FeatureSetByName&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;$map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Registration Submissions'&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;// create a sql expression to query on ID&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; sql &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"STATE_NAME = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; ID &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// filter the table using the sql expression&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; related_data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Filter&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sql&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// validate if you have any related records&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;related_data&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&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;// get the max date and format the result&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; maxepoch &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Max&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SubmissionDate'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; maxdate &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxepoch&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; format &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MM/DD/Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Text&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;maxdate&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; format&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="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;// in case you don't have related records&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;// define what to return&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string 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;/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 09:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788303#M66657</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T09:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788304#M66658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327406" target="_blank"&gt;Timothy Woodfield&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition have a look at the expression below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// create date 31st of January, note the month is 0:&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; dt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2020&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;31&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"date: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; dt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// extract the month value (will be 0)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Month&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"month: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;// format the date&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; format &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"MM/DD/Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; txt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Text&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dt&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; format&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;Console&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Formated date: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; txt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OK"&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will write the following to the console:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;date: 2020-01-31T00:00:00-05:00
month: 0
Formated date: 01/31/2020&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Be aware that when you use a Date function and need to specify the value for the month if will always be a value from 0 to 11. When you extract the month value from a date it will always be a value from 0 to 11. However, when you format a date it will&amp;nbsp;return the month as a value from 1 to 12 as shown in the example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:00:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788304#M66658</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T09:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788305#M66659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked! Thank you! I used this to set up a months since last submission which looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// first read out the ID of the Feature1&lt;BR /&gt;var id = $feature.STATE_NAME;&lt;BR /&gt;// access the table Feature2&lt;BR /&gt;var tbl = FeatureSetByName($map, 'Registration Submissions');&lt;BR /&gt;// create a sql expression to query on ID&lt;BR /&gt;var sql = "STATE_NAME = '" + ID + "'";&lt;BR /&gt;// filter the table using the sql expression&lt;BR /&gt;var related_data = Filter(tbl, sql);&lt;BR /&gt;// validate if you have any related records&lt;BR /&gt;if (Count(related_data)&amp;gt;0) {&lt;BR /&gt; // get the max date and format the result&lt;BR /&gt; var maxepoch = Max(tbl, 'SubmissionDate');&lt;BR /&gt; var maxdate = Date(maxepoch);&lt;BR /&gt; var endDate = Now();&lt;BR /&gt; var diff = DateDiff(endDate,maxdate,'months');&lt;BR /&gt; var age = Round(diff,0)&lt;BR /&gt; return age&lt;BR /&gt;} else {&lt;BR /&gt; // in case you don't have related records&lt;BR /&gt; // define what to return&lt;BR /&gt; return "No Previous Submissions";&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That all look correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another related question, is there a way to symbolize the polygons by this length since last submission? I thought I saw that the FeatureSetByName function isn't available for the symbology custom expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 23:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788305#M66659</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-08T23:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788306#M66660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327406"&gt;Timothy Woodfield&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad to hear that it is working. The code looks OK. I see that you are returning the rounded&amp;nbsp;age in months&amp;nbsp;since the latest submission.&lt;/P&gt;&lt;P&gt;As you noticed in the symbology profile you have no access to related data or other features. Therefore it is not possible to use the latest date to symbolize your features. You can calculate a field&amp;nbsp;to obtain the information, but this will not automatically update when the data changes. In Enterprise and Desktop you could use an Attribute Calculation Rule to update the age of the latest submission, but this functionality is not yet available in ArcGIS Online. As an alternative you could schedule a task in Pro with a certain frequency to update the field, but changes made to the data will not be reflected in the symbology.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Sep 2020 14:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788306#M66660</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-09-09T14:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Arcade DateDiff</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788307#M66661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Xander,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another followup question for you regarding the related records. How would I access another field from that row in the related record? I would still want to reference the row with the max date but would want to grab a name field associated with that record instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Sep 2020 20:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcgis-arcade-datediff/m-p/788307#M66661</guid>
      <dc:creator>Tim-Woodfield</dc:creator>
      <dc:date>2020-09-10T20:53:20Z</dc:date>
    </item>
  </channel>
</rss>

