<?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: Arcade Expression - Inspection Date in Current Quarter of Year in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1218773#M48203</link>
    <description>&lt;P&gt;It turns out that KenBuja's code needed a small change to the When functions.&lt;/P&gt;&lt;PRE&gt;var quarter = when (theMonth &amp;lt; 3, 1,
      theMonth &amp;lt; 6, 2,
      theMonth &amp;lt; 9, 3,
      theMonth &amp;lt; 12, 4,
      "Fail");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2022 19:19:30 GMT</pubDate>
    <dc:creator>AshleyHayes2</dc:creator>
    <dc:date>2022-10-04T19:19:30Z</dc:date>
    <item>
      <title>Arcade Expression - Inspection Date in Current Quarter of Year</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198040#M47190</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to write an Arcade expression that will determine if an inspection date occurred within the current quarter of the year (Jan-Mar, Apr-Jun, Jul-Sep, Oct-Dec).&amp;nbsp; My sense is that I need to convert the current date to quarter and the inspection date to quarter and see if they match, but I am not sure of the details for how to set that up.&amp;nbsp; Anyone done this before or have suggestions?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 15:42:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198040#M47190</guid>
      <dc:creator>AshleyHayes2</dc:creator>
      <dc:date>2022-08-01T15:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression - Inspection Date in Current Quarter of Year</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198055#M47191</link>
      <description>&lt;P&gt;Here's one way to do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var theDate = Date();
var testDate = Date(2022,7,4);

var theMonth = Month(theDate); //note Month is zero-based (Jan = 0)
var theYear = Year(theDate);
var quarter;
when (theMonth &amp;lt; 3, quarter = 1,
      theMonth &amp;lt; 6, quarter = 2,
      theMonth &amp;lt; 9, quarter = 3,
      quarter = 4);

var testMonth = Month(testDate);
var testYear = Year(testDate);
var testquarter;
when (testMonth &amp;lt; 3, testquarter = 1,
      testMonth &amp;lt; 6, testquarter = 2,
      testMonth &amp;lt; 9, testquarter = 3,
      testquarter = 4);
 
var output = "In current quarter";    
if (quarter != testquarter || theYear != testYear) output = "Not in current quarter";
return output;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 16:10:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198055#M47191</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-08-01T16:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression - Inspection Date in Current Quarter of Year</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198062#M47192</link>
      <description>&lt;P&gt;There isn't a function to directly pull out the quarter, but you could make your own using the month number easily enough. Assuming you already have a way of pulling your inspection date figured out, the rest of it could look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// return quarter for a given date
function Quarter(d){
    var month_num = Month(d)
    
    return When(
        month_num &amp;lt; 3, 1,
        month_num &amp;lt; 6, 2,
        month_num &amp;lt; 9, 3,
        4
    )
}

// get your inspection date; i'm using a prior date as a placeholder
var insp = Date(2022,7,13)

// get quarter and year for inspection
var i_qtr = Quarter(insp)
var i_yr = Year(insp)

Console(`Inspection occurred Q${i_qtr} of ${i_yr}.`)

// get current quarter and year
var curr_qtr = Quarter(Now())
var curr_yr = Year(Now())

// return True if inspection is in current year and quarter
i_qtr == curr_qtr &amp;amp;&amp;amp; i_yr == curr_yr&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Using a placeholder of sometime last month, I get a &lt;STRONG&gt;true&lt;/STRONG&gt;. Changing that to sometime in February, it switches to &lt;STRONG&gt;false&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Oh and here's the console output, just to show what that's doing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1659370679864.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/47441iF2C7FE5D7B4367F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1659370679864.png" alt="jcarlson_0-1659370679864.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 16:18:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1198062#M47192</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-01T16:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression - Inspection Date in Current Quarter of Year</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1199849#M47259</link>
      <description>&lt;P&gt;Worked great in my web map!&amp;nbsp; Now, is it possible to use or calculate that "current quarter" information in a Dashboard gauge or indicator?&amp;nbsp; Thanks!!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2022 15:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1199849#M47259</guid>
      <dc:creator>AshleyHayes2</dc:creator>
      <dc:date>2022-08-05T15:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression - Inspection Date in Current Quarter of Year</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1218773#M48203</link>
      <description>&lt;P&gt;It turns out that KenBuja's code needed a small change to the When functions.&lt;/P&gt;&lt;PRE&gt;var quarter = when (theMonth &amp;lt; 3, 1,
      theMonth &amp;lt; 6, 2,
      theMonth &amp;lt; 9, 3,
      theMonth &amp;lt; 12, 4,
      "Fail");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 19:19:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-inspection-date-in-current/m-p/1218773#M48203</guid>
      <dc:creator>AshleyHayes2</dc:creator>
      <dc:date>2022-10-04T19:19:30Z</dc:date>
    </item>
  </channel>
</rss>

