<?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 DateDiff Arcade Expression for Symbology in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364823#M56554</link>
    <description>&lt;P&gt;I created a Survey123 for road construction which includes two date type fields, one for when the construction begins and one field for when the construction ends, and I want to symbolize the features using those two date fields. Specifically I want to symbolize the features by what happened last week, "Construction Started Last Week", "Construction Ended Last Week", "Construction Was Active Last Week", and an "Other" symbology for those features whose start construction date and end construction date are outside the last week parameters.&lt;/P&gt;&lt;P&gt;//Here is an expression I tried to use to symbolize this, but it didn't work, every feature had "Other" symbology:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;var&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; = &lt;FONT color="#0000FF"&gt;DateDiff&lt;/FONT&gt;(&lt;FONT color="#0000FF"&gt;Now&lt;/FONT&gt;(), $&lt;FONT color="#0000FF"&gt;feature.start_closure&lt;/FONT&gt;,&lt;FONT color="#993300"&gt;'days'&lt;/FONT&gt;&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;var&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; = &lt;FONT color="#0000FF"&gt;DateDiff&lt;/FONT&gt;(&lt;FONT color="#0000FF"&gt;Now&lt;/FONT&gt;(),&lt;FONT color="#0000FF"&gt; $feature.end_closure&lt;/FONT&gt;, &lt;FONT color="#993300"&gt;'days'&lt;/FONT&gt;&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;If&lt;/FONT&gt; (&lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; &amp;gt;= &lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &amp;amp;&amp;amp; &lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; &amp;lt;= &lt;FONT color="#008000"&gt;7&lt;/FONT&gt;) {&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; return "Active last week"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;else if&lt;/FONT&gt; (&lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; &amp;gt;= &lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &amp;amp;&amp;amp; &lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; &amp;lt;=&lt;FONT color="#008000"&gt;7&lt;/FONT&gt;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;FONT color="#993300"&gt;return "Ended Last Week"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;} &lt;FONT color="#993300"&gt;else&lt;/FONT&gt;{&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; return "Other"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help!&lt;/P&gt;</description>
    <pubDate>Thu, 28 Dec 2023 19:19:12 GMT</pubDate>
    <dc:creator>brandonmann3</dc:creator>
    <dc:date>2023-12-28T19:19:12Z</dc:date>
    <item>
      <title>DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364823#M56554</link>
      <description>&lt;P&gt;I created a Survey123 for road construction which includes two date type fields, one for when the construction begins and one field for when the construction ends, and I want to symbolize the features using those two date fields. Specifically I want to symbolize the features by what happened last week, "Construction Started Last Week", "Construction Ended Last Week", "Construction Was Active Last Week", and an "Other" symbology for those features whose start construction date and end construction date are outside the last week parameters.&lt;/P&gt;&lt;P&gt;//Here is an expression I tried to use to symbolize this, but it didn't work, every feature had "Other" symbology:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;var&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; = &lt;FONT color="#0000FF"&gt;DateDiff&lt;/FONT&gt;(&lt;FONT color="#0000FF"&gt;Now&lt;/FONT&gt;(), $&lt;FONT color="#0000FF"&gt;feature.start_closure&lt;/FONT&gt;,&lt;FONT color="#993300"&gt;'days'&lt;/FONT&gt;&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;var&lt;/FONT&gt; &lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; = &lt;FONT color="#0000FF"&gt;DateDiff&lt;/FONT&gt;(&lt;FONT color="#0000FF"&gt;Now&lt;/FONT&gt;(),&lt;FONT color="#0000FF"&gt; $feature.end_closure&lt;/FONT&gt;, &lt;FONT color="#993300"&gt;'days'&lt;/FONT&gt;&lt;FONT color="#000000"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;If&lt;/FONT&gt; (&lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; &amp;gt;= &lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &amp;amp;&amp;amp; &lt;FONT color="#0000FF"&gt;startedlastweek&lt;/FONT&gt; &amp;lt;= &lt;FONT color="#008000"&gt;7&lt;/FONT&gt;) {&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; return "Active last week"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;else if&lt;/FONT&gt; (&lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; &amp;gt;= &lt;FONT color="#008000"&gt;1&lt;/FONT&gt; &amp;amp;&amp;amp; &lt;FONT color="#0000FF"&gt;endedlastweek&lt;/FONT&gt; &amp;lt;=&lt;FONT color="#008000"&gt;7&lt;/FONT&gt;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;FONT color="#993300"&gt;return "Ended Last Week"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;} &lt;FONT color="#993300"&gt;else&lt;/FONT&gt;{&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&amp;nbsp; return "Other"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 19:19:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364823#M56554</guid>
      <dc:creator>brandonmann3</dc:creator>
      <dc:date>2023-12-28T19:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364842#M56555</link>
      <description>&lt;P&gt;Try throwing in &lt;STRONG&gt;Console(startedlastweek)&lt;/STRONG&gt; and see what it's returning. DateDiff usually expects the later date to come first, so you might be getting negative numbers?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 20:12:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364842#M56555</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-12-28T20:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364844#M56556</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/610578"&gt;@brandonmann3&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var A = DateDiff(Now(), $feature.start_closure , 'days' )
var B = DateDiff(Now(), $feature.end_closure , 'days' )
var Condition = Null
if ( A &amp;lt;= 7 ){ Condition = "Active last week" }
else if ( B &amp;lt;= 7 &amp;amp;&amp;amp; A &amp;gt; 7 ){ Condition = "Ended Last Week" }
else { Condition = "Other" }
Console( Condition )
return Condition&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 20:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1364844#M56556</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2023-12-28T20:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365026#M56570</link>
      <description>&lt;P&gt;Thank you for the quick response&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;it works almost perfectly. The only problem with it though is if the feature's start date is today or in the future it is symbolized as "Active last week".&lt;/P&gt;&lt;P&gt;Features with a start date today or in the future, and an end date of today or in future it is labeled as "Ended last week".&lt;/P&gt;&lt;P&gt;Is the limitation of the DateDiff function that it cannot tell the difference between positive and negative difference, and I should be using something else for this symbology?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two highlighted examples show the symbology issue I described:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brandonmann3_0-1703874703977.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90147iE0A8EAF89B12EF7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brandonmann3_0-1703874703977.png" alt="brandonmann3_0-1703874703977.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 18:32:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365026#M56570</guid>
      <dc:creator>brandonmann3</dc:creator>
      <dc:date>2023-12-29T18:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365108#M56575</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/610578"&gt;@brandonmann3&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You could set it to identify if the future date is greater than now which would solve your issue.&lt;/P&gt;&lt;P&gt;Add&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;now() &amp;lt; $feature.start_closure&lt;/EM&gt;&lt;/STRONG&gt; to the first if statement and&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;now() &amp;lt; $feature.end_closure&lt;/EM&gt;&lt;/STRONG&gt; to the second if statement and that should work.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 23:42:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365108#M56575</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2023-12-29T23:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365423#M56587</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/22623"&gt;@RPGIS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I'm a bit inexperienced with arcade, where exactly do I need to put that in each line?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 16:39:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365423#M56587</guid>
      <dc:creator>brandonmann3</dc:creator>
      <dc:date>2024-01-02T16:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365518#M56597</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/610578"&gt;@brandonmann3&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if ( A &amp;lt;= 7 &amp;amp;&amp;amp;&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;now() &amp;lt; $feature.start_closure&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;else if ( B &amp;lt;= 7 &amp;amp;&amp;amp; A &amp;gt; 7 &amp;amp;&amp;amp;&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;now() &amp;lt; $feature.end_closure&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var start = $feature.start_closure
var end = $feature.end_closure
var A = DateDiff(Now(), start  , 'days' )
var B = DateDiff(Now(), end  , 'days' )
var Condition = Null
if ( A &amp;lt;= 7 &amp;amp;&amp;amp; start &amp;lt; now()){ Condition = "Active last week" }
else if ( B &amp;lt;= 7 &amp;amp;&amp;amp; A &amp;gt; 7 &amp;amp;&amp;amp; end &amp;lt; now() ){ Condition = "Ended Last Week" }
else { Condition = "Other" }
Console( Condition )
return Condition&lt;/LI-CODE&gt;&lt;P&gt;Insert either of the characters below in parentheses if you want to combine statements&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;&amp;amp;&amp;amp;&amp;nbsp;&lt;/STRONG&gt;is equal to 'AND'&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;||&amp;nbsp;&lt;/STRONG&gt;is equal to 'OR'&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 19:18:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365518#M56597</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2024-01-02T19:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff Arcade Expression for Symbology</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365619#M56603</link>
      <description>&lt;P&gt;Thank you so much for your help this was great. I added an additional line to include any features created before last week and end after today.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;else&lt;/SPAN&gt; &lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;start&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt; &lt;/SPAN&gt;&lt;SPAN&gt;now&lt;/SPAN&gt;&lt;SPAN&gt;() &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;end&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;now&lt;/SPAN&gt;&lt;SPAN&gt;() ) {&lt;/SPAN&gt;&lt;SPAN&gt;Condition&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"Active last week"&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jan 2024 22:03:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/datediff-arcade-expression-for-symbology/m-p/1365619#M56603</guid>
      <dc:creator>brandonmann3</dc:creator>
      <dc:date>2024-01-02T22:03:34Z</dc:date>
    </item>
  </channel>
</rss>

