<?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: If Statements in Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/if-statements-in-arcade/m-p/343419#M17156</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use IsEmpty to check and see if the date is null&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; open &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;2018&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;01&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10&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; closed &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//Date(2018,01,12);&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;IsEmpty&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;closed&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;"No Closed Date"&lt;/SPAN&gt;&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// closed date listed so calculate fine &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; closedDiff &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;DateDiff&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;closed&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'days'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"$"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;25&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; closedDiff&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as far as the odd results you are getting with DateDiff for open its probably because in Arcade month is 0 based so 0 is January so your calculation may be off by a month.&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/arcade/function-reference/date_functions/#date" title="https://developers.arcgis.com/arcade/function-reference/date_functions/#date" rel="nofollow noopener noreferrer" target="_blank"&gt;Date Functions | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:11:18 GMT</pubDate>
    <dc:creator>KellyHutchins</dc:creator>
    <dc:date>2021-12-11T16:11:18Z</dc:date>
    <item>
      <title>If Statements in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/if-statements-in-arcade/m-p/343418#M17155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on a script currently in Arcade that is giving me some trouble, although it shouldn't seem like it would. I have a survey where field inspectors go in an log the date that a citation is issued. A person is charged $25 per day for the citation. However, that amount is halted when the inspector issues a completion date.&amp;nbsp; Therefore I have a conditional statement where, if the closed date is empty, then the person will continue to be charged the $25 on a daily basis until it is closed. If the closed date is filled in, the person will be charged the total from however many days it was from the day the citation started until it closed. Here is what I have right now: (I amusing the "Now" function because I am unsure of how to say if it is "Null" use this)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var open = Date($feature.DateofCitationTag);&lt;BR /&gt;var closed = Date($feature.CitationClosed);&lt;BR /&gt;var present = Today();&lt;BR /&gt;var closedDiff = DateDiff(closed, open, 'days');&lt;BR /&gt;var openDiff = DateDiff(present, open, 'days');&lt;BR /&gt;var closedAmount = 25 * closedDiff&lt;BR /&gt;var openAmount = 25 * openDiff&lt;BR /&gt;if (closed &amp;lt;= Now()) {&lt;BR /&gt; return "$" + closedAmount &lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt; return "$" + openAmount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The closedAmount shows up and is calculated correctly. However, the openAmount has been giving me a crazy value of $-438380.2083333 when the amount should be $200 (taking into consideration 8 days at $25 per day and counting). I am unsure of why it is acting this way. Anyone have any experience with a conditional statement like this? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/if-statements-in-arcade/m-p/343418#M17155</guid>
      <dc:creator>deleted-user-FTxtuSQd67Ur</dc:creator>
      <dc:date>2018-01-11T20:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: If Statements in Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/if-statements-in-arcade/m-p/343419#M17156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use IsEmpty to check and see if the date is null&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; open &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;2018&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;01&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10&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; closed &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;//Date(2018,01,12);&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;IsEmpty&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;closed&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &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;"No Closed Date"&lt;/SPAN&gt;&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// closed date listed so calculate fine &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; closedDiff &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;DateDiff&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;closed&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'days'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"$"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;25&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt; closedDiff&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as far as the odd results you are getting with DateDiff for open its probably because in Arcade month is 0 based so 0 is January so your calculation may be off by a month.&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/arcade/function-reference/date_functions/#date" title="https://developers.arcgis.com/arcade/function-reference/date_functions/#date" rel="nofollow noopener noreferrer" target="_blank"&gt;Date Functions | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:11:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/if-statements-in-arcade/m-p/343419#M17156</guid>
      <dc:creator>KellyHutchins</dc:creator>
      <dc:date>2021-12-11T16:11:18Z</dc:date>
    </item>
  </channel>
</rss>

