<?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: Date Calculation in Arcade in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281085#M7670</link>
    <description>&lt;P&gt;Even with the comparison being done on text forms of the datetime, the formatting should allow for the comparison to work as intended.&amp;nbsp; I'm wondering if timezones are a factor here and ToUTC() should be implemented.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://arcgis.com"); 
var accidents = FeatureSetByPortalItem(portal, "********",1, ['*'], true)
var t1 = Text(ToUTC(Now()),'Y-MM-DD HH:mm')
var t2 = Text(DateAdd(t1, -24, 'hours'),'Y-MM-DD HH:mm')
var sql = "call &amp;gt; @t2"
Console("call &amp;gt; " + t2)
var recent_accidents = Filter(accidents, sql)

for (var s in recent_accidents) {
  Console(Text(ToUTC(s.call),'Y-MM-DD HH:mm'))&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 20 Apr 2023 22:33:48 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2023-04-20T22:33:48Z</dc:date>
    <item>
      <title>Date Calculation in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281028#M7668</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In a data expression, I'm filtering a feature layer of 911 calls to those in the last 24 hours. The filter often returns more records than I think it should&lt;/P&gt;&lt;P&gt;Here is the Arcade:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var portal = Portal("https://arcgis.com"); 
var accidents = FeatureSetByPortalItem(portal, "********",1, ['*'], true)
var t1 = Text(Now(),'Y-MM-DD HH:mm')
var t2 = Text(DateAdd(t1, -24, 'hours'),'Y-MM-DD HH:mm')
var sql = "call &amp;gt; @t2"
Console("call &amp;gt; " + t2)
var recent_accidents = Filter(accidents, sql)

for (var s in recent_accidents) {
  Console(Text(s.call,'Y-MM-DD HH:mm'))
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JillianStanford_0-1682023329551.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/68649i6620D4B69A92D634/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JillianStanford_0-1682023329551.png" alt="JillianStanford_0-1682023329551.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can't figure out why the call at 14:02 is not being filtered out, even though it occurs before 15:33.&lt;/P&gt;&lt;P&gt;Can someone point out my error here?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Jill&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 20:50:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281028#M7668</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2023-04-20T20:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281085#M7670</link>
      <description>&lt;P&gt;Even with the comparison being done on text forms of the datetime, the formatting should allow for the comparison to work as intended.&amp;nbsp; I'm wondering if timezones are a factor here and ToUTC() should be implemented.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://arcgis.com"); 
var accidents = FeatureSetByPortalItem(portal, "********",1, ['*'], true)
var t1 = Text(ToUTC(Now()),'Y-MM-DD HH:mm')
var t2 = Text(DateAdd(t1, -24, 'hours'),'Y-MM-DD HH:mm')
var sql = "call &amp;gt; @t2"
Console("call &amp;gt; " + t2)
var recent_accidents = Filter(accidents, sql)

for (var s in recent_accidents) {
  Console(Text(ToUTC(s.call),'Y-MM-DD HH:mm'))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 22:33:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281085#M7670</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-04-20T22:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281387#M7671</link>
      <description>&lt;P&gt;That seems to have done the trick! Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 17:00:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/date-calculation-in-arcade/m-p/1281387#M7671</guid>
      <dc:creator>JillianStanford</dc:creator>
      <dc:date>2023-04-21T17:00:45Z</dc:date>
    </item>
  </channel>
</rss>

