<?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: DateDiff Help in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169397#M1114</link>
    <description>&lt;P&gt;Thanks Josh!&lt;/P&gt;&lt;P&gt;I did play around with that. When I use&amp;nbsp;&lt;STRONG&gt;$feature['InspectionDate']&lt;/STRONG&gt;, it returns a&amp;nbsp;&lt;SPAN&gt;Runtime Error: Identifier Not Found. InspectionDate. I'm pulling the 'InspectionDate' from my list of Globals and all of the test data is filled out with dates. Do I need to do something special to indicate that the 'InspectionDate' is in the related table of the $feature?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Fri, 29 Apr 2022 16:44:01 GMT</pubDate>
    <dc:creator>MaryEllenStRomain</dc:creator>
    <dc:date>2022-04-29T16:44:01Z</dc:date>
    <item>
      <title>DateDiff Help</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169379#M1112</link>
      <description>&lt;P&gt;Hey everyone!&lt;/P&gt;&lt;P&gt;I'm very new to Arcade, so bear with me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my AGO map, I have a "Parks" point layer and it's related "Assessments" table. I am trying to calculate a field in the "Parks" layer to display the days since the last assessment, based on the date field in the "Assessments" table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that I need to use the DateDiff function, but it seems to be having a problem finding the related table and date field I'm wanting to point to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The relationship is a 1:M, and I'd like to pull the most recent assessment date. I'm not sure if it's the syntax or the 1:M that is causing an error:&lt;/P&gt;&lt;P&gt;var startDate = Date();&lt;BR /&gt;var endDate = Date(InspectionDate);&lt;BR /&gt;var age = DateDiff(endDate, startDate, 'days');&lt;BR /&gt;return age;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN&gt;Runtime Error: Identifier Not Found. InspectionDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be much appreciated!&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 16:10:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169379#M1112</guid>
      <dc:creator>MaryEllenStRomain</dc:creator>
      <dc:date>2022-04-29T16:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Help</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169393#M1113</link>
      <description>&lt;P&gt;To access an attribute, you need to put&amp;nbsp;&lt;STRONG&gt;$feature.&lt;/STRONG&gt; in front of the attribute name. You can also use bracket notation, like&amp;nbsp;&lt;STRONG&gt;$feature['InspectionDate']&lt;/STRONG&gt; to pull in an attribute.&lt;/P&gt;&lt;P&gt;Without the&amp;nbsp;&lt;STRONG&gt;$feature.&lt;/STRONG&gt;, the expression is looking for a &lt;EM&gt;variable&amp;nbsp;&lt;/EM&gt;called "InspectionDate".&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 16:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169393#M1113</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-29T16:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Help</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169397#M1114</link>
      <description>&lt;P&gt;Thanks Josh!&lt;/P&gt;&lt;P&gt;I did play around with that. When I use&amp;nbsp;&lt;STRONG&gt;$feature['InspectionDate']&lt;/STRONG&gt;, it returns a&amp;nbsp;&lt;SPAN&gt;Runtime Error: Identifier Not Found. InspectionDate. I'm pulling the 'InspectionDate' from my list of Globals and all of the test data is filled out with dates. Do I need to do something special to indicate that the 'InspectionDate' is in the related table of the $feature?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 16:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169397#M1114</guid>
      <dc:creator>MaryEllenStRomain</dc:creator>
      <dc:date>2022-04-29T16:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Help</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169398#M1115</link>
      <description>&lt;P&gt;Since you're working with a related table, you have to use FeatureSetByRelationshipName to get the values in that table. Here's an example (and the output):&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var test = FeatureSetByRelationshipName($feature,"Source");
for (var f in test) {
    var output = f.Year;
    console(output)
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="year.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40234i5AED74F51AAEF548/image-size/medium?v=v2&amp;amp;px=400" role="button" title="year.png" alt="year.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 16:44:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169398#M1115</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-04-29T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Help</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169420#M1116</link>
      <description>&lt;P&gt;Oh jeez, I'm sorry. I went through your post way too quick and just focused on the code portion once I saw that it wasn't accessing a specific feature. More generally, you need to specify a feature to get its attributes, so it's not always $feature, but it needs to be a&amp;nbsp;&lt;EM&gt;feature&amp;nbsp;&lt;/EM&gt;object.&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;points out, you need to use another function to access related records.&lt;/P&gt;&lt;P&gt;In text:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Get the related records&lt;/LI&gt;&lt;LI&gt;Sort by date&lt;/LI&gt;&lt;LI&gt;Grab the first record&lt;/LI&gt;&lt;LI&gt;Pull out the date&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// related records
var rel = FeatureSetByRelationshipName(
    $feature,
    'Inspections', // the name here will vary, see note below code snippet
    ['InspectionDate'],
    false
)

// get the latest one as a feature
var latest = First(
    OrderBy(
        rel,
        'InspectionDate DESC'
    )
)

// return the timestamp of the latest inspection
return latest['InspectionDate']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; For the relationship name, the expression builder can pipe that in for you, if you don't know it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brave_N9xXA2sXyz.gif" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/40236i76B74083E2D364B7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brave_N9xXA2sXyz.gif" alt="brave_N9xXA2sXyz.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 17:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/datediff-help/m-p/1169420#M1116</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-04-29T17:36:50Z</dc:date>
    </item>
  </channel>
</rss>

