<?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 Model Builder to extract Year/Month from datestamp and calculate financial period in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045825#M39565</link>
    <description>&lt;P&gt;&lt;A href="https://paulcunningham.dev/python-date-time-fiscal-year/" target="_blank"&gt;Calculating Fiscal Year Dates With Python | Coding and Development Blog (paulcunningham.dev)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which references&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/adamjstewart/fiscalyear" target="_blank"&gt;adamjstewart/fiscalyear: Utilities for managing the fiscal calendar (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;which leads to the script&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/adamjstewart/fiscalyear/blob/master/fiscalyear.py" target="_blank"&gt;fiscalyear/fiscalyear.py at master · adamjstewart/fiscalyear (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So if you don't want to import the package, you can at least look at the source code to extract the salient parts&lt;/P&gt;</description>
    <pubDate>Mon, 12 Apr 2021 06:28:47 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-04-12T06:28:47Z</dc:date>
    <item>
      <title>Using Model Builder to extract Year/Month from datestamp and calculate financial period</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045805#M39560</link>
      <description>&lt;P&gt;Hi Brains Trust. I'm working on a model and starting to delve deeper into parts I've not really used a lot before - especially not in combination. Here's the scenario.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a feature class that contains a field called DateS which contains date stamps formatted like this:&amp;nbsp;2020-11-16T00:02:58.096Z&lt;/P&gt;&lt;P&gt;I want to be able to iterate through all the different dates in that column (easy enough using Iterate Field Values), extract the Year and Month (I assume that will be Get Value) and then run a formula to calulate the Australian Financial Year (July - June) that the date range falls in. Example of some output values;&lt;/P&gt;&lt;P&gt;Input from DateS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp; &amp;nbsp; Output as Financial Year (YEAR-Y1)&lt;/P&gt;&lt;P&gt;2020-11-16T00:02:58.096Z &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; 2020-21&lt;/P&gt;&lt;P&gt;2020-06-16T00:02:58.096Z &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; 2019-20&lt;/P&gt;&lt;P&gt;2019-10-16T00:02:58.096Z &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; 2019-20&lt;/P&gt;&lt;P&gt;2019-03-16T00:02:58.096Z &amp;nbsp; &amp;nbsp; &amp;nbsp; -&amp;nbsp; &amp;nbsp; &amp;nbsp; 2018-19&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LindsayRaabe_FPCWA_0-1618193751886.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/10591iF88967C44B79B108/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LindsayRaabe_FPCWA_0-1618193751886.png" alt="LindsayRaabe_FPCWA_0-1618193751886.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 02:17:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045805#M39560</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2021-04-12T02:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Model Builder to extract Year/Month from datestamp and calculate financial period</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045825#M39565</link>
      <description>&lt;P&gt;&lt;A href="https://paulcunningham.dev/python-date-time-fiscal-year/" target="_blank"&gt;Calculating Fiscal Year Dates With Python | Coding and Development Blog (paulcunningham.dev)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which references&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/adamjstewart/fiscalyear" target="_blank"&gt;adamjstewart/fiscalyear: Utilities for managing the fiscal calendar (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;which leads to the script&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/adamjstewart/fiscalyear/blob/master/fiscalyear.py" target="_blank"&gt;fiscalyear/fiscalyear.py at master · adamjstewart/fiscalyear (github.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So if you don't want to import the package, you can at least look at the source code to extract the salient parts&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 06:28:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045825#M39565</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-04-12T06:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using Model Builder to extract Year/Month from datestamp and calculate financial period</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045842#M39567</link>
      <description>&lt;P&gt;This looks like a simple job for Python or Arcade.&lt;/P&gt;&lt;P&gt;Python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# values in Date fields in ArcGis are datetime.datetime objects
import datetime
def get_financial_year(timestamp):
    """Returns the Australian financial year of the given timestamp (as datetime.datetime object) as a string."""
    year = timestamp.year
    if timestamp.month &amp;gt;= 7:
        return "{}-{}".format(year, str(year+1)[-2:])
    return "{}-{}".format(year-1, str(year)[-2:])


# to test it:
timestamps = [
    datetime.datetime(2020, 11, 16, 0, 2, 58),
    datetime.datetime(2020, 6, 16, 0, 2, 58),
    datetime.datetime(2019, 10, 16, 0, 2, 58),
    datetime.datetime(2019, 3, 16, 0, 2, 58),
    ]
for ts in timestamps:
    print(get_financial_year(ts))
#2020-21
#2019-20
#2019-20
#2018-19&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use that in the CalculateField tool (so you can also use it as part of a model), or you can just keep working with python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc_path = "path/to/your/feature/class"
date_field = "Timestamp"
financial_year_field = "FinancialYear"

with arcpy.da.UpdateCursor(fc_path, [date_field, financial_year_field]) as cursor:
    for date, year in cursor:
        cursor.updateRow([date, get_financial_year(date)])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Apr 2021 08:15:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-model-builder-to-extract-year-month-from/m-p/1045842#M39567</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-04-12T08:15:08Z</dc:date>
    </item>
  </channel>
</rss>

