<?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: Using a Date in an Arcade Filter Function in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1198321#M47201</link>
    <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;Thanks for providing this alternate solution.&amp;nbsp; Sorry it took so long to respond.&amp;nbsp; I was waiting to hear back from Esri on a support ticket related to this before I responded. You are right that it was a time zone issue, so we just republished the data and specified the time zone to take care of the issue.&amp;nbsp;&amp;nbsp;I did try using the Extract function in my SQL statement, but I couldn't get it to work, even when I stripped my SQL statement down to using just a single EXTRACT function.&amp;nbsp; I was getting an error, but the error was very generic so wasn't much help in troubleshooting. But we are good now. Just wanted to thank you for responding.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 22:49:04 GMT</pubDate>
    <dc:creator>TomFlahive1</dc:creator>
    <dc:date>2022-08-01T22:49:04Z</dc:date>
    <item>
      <title>Using a Date in an Arcade Filter Function</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1184890#M46561</link>
      <description>&lt;P&gt;I am using an Arcade Filter function in an attribute expression.&amp;nbsp; I am trying to pull back all records that were created today.&amp;nbsp; The sqlExpression looks like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;var nestSurveySql = "NestGlobalID = '" + nestRec.GlobalID + "' AND survey_date &amp;gt; '" + Today() + "'";&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output to the console from this sql string looks like this:&lt;/P&gt;&lt;PRE&gt;NestGlobalID = '2e6b7d-0586-44a8-9e54-bf1f01e3' AND survey_date &amp;gt; '2022-06-21T00:00:00-07:00'&lt;/PRE&gt;&lt;P&gt;This seems to work as it does return records.&amp;nbsp; However, it is returning two records when I was only expecting one.&amp;nbsp; The extra record has a date that is from the day before today:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;2022-06-20T17:55:33.196-07:00
2022-06-21T08:37:23.667-07:00&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is there a way to format this sql expression so that it works properly and only returns records for today?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 22:06:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1184890#M46561</guid>
      <dc:creator>TomFlahive1</dc:creator>
      <dc:date>2022-06-21T22:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Date in an Arcade Filter Function</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1185104#M46568</link>
      <description>&lt;P&gt;I would guess that this is happening because of time zone differences between your machine and the server. If you're really looking for anything with today's date, you can also try to use&amp;nbsp;&lt;STRONG&gt;EXTRACT&lt;/STRONG&gt; in your SQL. Instead of using "&amp;gt;", we could check if the year/month/date match. Maybe a bit clunkier, but it ought to account for differences in time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, rather than concatenating strings for you statement, you can use&amp;nbsp;&lt;STRONG&gt;template literals&lt;/STRONG&gt; to pipe things into the string. I find them easier to make sense of than juggling lots of separate strings. It also respects line breaks, so you can keep your SQL nicely formatted, if that's something you want to do.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var nestSurveySql = `NestGlobalID = ${nestRec.GlobalID} AND
EXTRACT(YEAR FROM survey_date) = EXTRACT(YEAR FROM '${Today()}') AND
EXTRACT(MONTH FROM survey_date) = EXTRACT(MONTH FROM '${Today()}') AND
EXTRACT(DAY FROM survey_date) = EXTRACT(DAY FROM '${Today()}')
`&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 15:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1185104#M46568</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-06-22T15:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Date in an Arcade Filter Function</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1198321#M47201</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;Thanks for providing this alternate solution.&amp;nbsp; Sorry it took so long to respond.&amp;nbsp; I was waiting to hear back from Esri on a support ticket related to this before I responded. You are right that it was a time zone issue, so we just republished the data and specified the time zone to take care of the issue.&amp;nbsp;&amp;nbsp;I did try using the Extract function in my SQL statement, but I couldn't get it to work, even when I stripped my SQL statement down to using just a single EXTRACT function.&amp;nbsp; I was getting an error, but the error was very generic so wasn't much help in troubleshooting. But we are good now. Just wanted to thank you for responding.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 22:49:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-a-date-in-an-arcade-filter-function/m-p/1198321#M47201</guid>
      <dc:creator>TomFlahive1</dc:creator>
      <dc:date>2022-08-01T22:49:04Z</dc:date>
    </item>
  </channel>
</rss>

