<?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: How to populate a new field with integer year extracted from date field in arcpy in ArcGIS Analyse Questions</title>
    <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773576#M29</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have &lt;STRONG&gt;Python&lt;/STRONG&gt; checked at the top of the Field Calculator?&amp;nbsp; Can you send a screen shot of the Field Calculator?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2020 19:52:32 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2020-04-21T19:52:32Z</dc:date>
    <item>
      <title>How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773573#M26</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I recognize this is a question that has been asked before (I have included some links and strings below that are related), but I have not found a solution, and I am likely making a mistake that is now opaque to me, so I am hoping for assistance here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solutions I have found seem to use Arcade, VB, and/or the GUI Field Calculator (the Field Calculator works, but I would like to automate the process in a script).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I I would like to do is create a new field "inspectionyear", and populate it with an integer for the year, extracted from another date field "inspection_date".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Creating the new field is straight forward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #8c8c8c;"&gt;# Import modules
&lt;/SPAN&gt;&lt;SPAN style="color: #0033b3;"&gt;import &lt;/SPAN&gt;arcpy, datetime &lt;SPAN style="color: #8c8c8c;"&gt;# Provides access to arcpy tools
&lt;/SPAN&gt;&lt;SPAN style="color: #0033b3;"&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN style="color: #0033b3;"&gt;import &lt;/SPAN&gt;time
&lt;SPAN style="color: #0033b3;"&gt;from &lt;/SPAN&gt;datetime &lt;SPAN style="color: #0033b3;"&gt;import &lt;/SPAN&gt;*

&lt;SPAN style="color: #8c8c8c;"&gt;# Add a new field to contain the year integer
&lt;/SPAN&gt;arcpy.env.workspace = &lt;SPAN style="color: #008080; font-weight: bold;"&gt;"C/DataFiles/DataSource.dbf"
&lt;/SPAN&gt;arcpy.DeleteField_management(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"DataSource.dbf"&lt;/SPAN&gt;,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"inspectionyear"&lt;/SPAN&gt;) &lt;SPAN style="color: #8c8c8c;"&gt;# If a field with the name "yearvalue" already exists, delete it
&lt;/SPAN&gt;arcpy.AddField_management(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"DataSource.dbf"&lt;/SPAN&gt;,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"yearfield"&lt;/SPAN&gt;,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"INTEGER"&lt;/SPAN&gt;) &lt;SPAN style="color: #8c8c8c;"&gt;# Create the field that will hold the year integers.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I have not successfully extracted the year values and added them to the new field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried using the GUI Field Calculator as shown:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="489476" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/489476_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The process runs and closes successfully, with no errors, however, the inspectionyear field remains populated with &amp;lt;NULL&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried using the VB function in arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.CalculateField_management(inputtable,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"inspectionyear"&lt;/SPAN&gt;,DatePart(&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"yyyy"&lt;/SPAN&gt;,[fulldate]),&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"VB"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which produces:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NameError: name 'DatePart' is not defined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I have also tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;datevalues = datetime.datetime.strftime(!inspection_date!,&lt;SPAN style="color: #008080; font-weight: bold;"&gt;"%-m/%-d/%Y"&lt;/SPAN&gt;)&lt;SPAN style="color: #8c8c8c;"&gt;
&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To simply retrieve the year, but end up with a syntax error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone recommend a way to retrieve the year value, or point me in the direction of a guide?&amp;nbsp; I have already explored quite a few links, including but not limited to the following.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000021112" rel="nofollow noopener noreferrer" target="_blank"&gt;Arcade approach&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/thread/178121?commentID=791486#comment" target="_blank"&gt;Matching question posed by other user, but not answered&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/10.3/manage-data/tables/working-with-date-fields-making-simple-date-field-.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Field Calculator GUI method that ran, but did not populate the field&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/manage-data/tables/fundamentals-of-date-fields.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Info on generating datetime objects&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773573#M26</guid>
      <dc:creator>RobertTrotter</dc:creator>
      <dc:date>2021-12-12T08:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773574#M27</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're date is in the following format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8/23/2019 12:08:19 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;str(!EditDate!)[5:9]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/489479_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 18:36:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773574#M27</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2020-04-21T18:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773575#M28</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jake, thanks for the suggestion, I gave it a try, but it generated the same issue the VB language generated.&amp;nbsp; The process runs and closes successfully and does not generate any errors, but the field remains blank.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 19:34:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773575#M28</guid>
      <dc:creator>RobertTrotter</dc:creator>
      <dc:date>2020-04-21T19:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773576#M29</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have &lt;STRONG&gt;Python&lt;/STRONG&gt; checked at the top of the Field Calculator?&amp;nbsp; Can you send a screen shot of the Field Calculator?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 19:52:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773576#M29</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2020-04-21T19:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773577#M30</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/489498_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a screen shot from running it.&amp;nbsp; However, it occurs to me that this also may not work (even if it does populate the field), since it will attempt to extract characters 5 through 9, and since months and days can include 1 or 2 digits, the indices would shift.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 20:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773577#M30</guid>
      <dc:creator>RobertTrotter</dc:creator>
      <dc:date>2020-04-21T20:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773578#M31</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An ugly workaround to deal with shifting month and day lengths is to split on the separator.&amp;nbsp; If you have no 'time' you can omit the last split&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;z &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"8/23/2019 12:08:19 PM"&lt;/SPAN&gt;
z&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string 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="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string 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="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'2019'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you are using an alternate format then you have to adjust the slicing, as in the international standard format.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;z &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"2019/8/23 12:08:19 PM"&lt;/SPAN&gt;

z&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string 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="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;'2019'&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:39:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773578#M31</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T08:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773579#M32</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That makes sense (and I am happy for a solution, ugly, elegant, or just odd), however would this approach require me to loop through each feature/row in the table, updating the value?&amp;nbsp; It seems odd that there is not simply a function to export a year from a date field as a "FLOAT", or other format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is datetime.datetime.strftime(!fulldate!, "%-m/%-d/%Y") the right tree to be barking up to extract the year?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate your time with this, I am learning how little I know about arcpy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 20:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773579#M32</guid>
      <dc:creator>RobertTrotter</dc:creator>
      <dc:date>2020-04-21T20:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773580#M33</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe this will help.&amp;nbsp; The format is for my datetime settings&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;n = datetime.datetime.now()
now_str = datetime.datetime.strftime(n, "%Y-%m-%d")
now_str.split("-")[0]
'2020'&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:40:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773580#M33</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T08:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773581#M34</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two more failed efforts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the Field Calculator GUI, the VB code:&lt;/P&gt;&lt;P&gt;year = DatePart("yyyy",[fulldate])&lt;/P&gt;&lt;P&gt;seems to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, using the arcpy line&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management(datatable,year,DatePart("yyyy",[fulldate]),"VB")&lt;/P&gt;&lt;P&gt;generates the error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management(datatable,year,DatePart("yyyy",[fulldate]),"VB")&lt;BR /&gt;NameError: name 'DatePart' is not defined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not clear to my why the VB script is not working.&amp;nbsp; But as an alternative, it seems that I could instead use&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management(datatable,year,expression,"Python_9_3"),&lt;/P&gt;&lt;P&gt;and use something like&lt;/P&gt;&lt;P&gt;expression = !fulldate!.year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since the field fulldate is already defined as a date field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 21:59:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773581#M34</guid>
      <dc:creator>RobertTrotter</dc:creator>
      <dc:date>2020-04-21T21:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773582#M35</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/help/data/tables/date-fields.htm" title="https://pro.arcgis.com/en/pro-app/help/data/tables/date-fields.htm"&gt;Date fields—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are dates, then there are dates.&amp;nbsp; Which is why I avoid using date fields, and convert to string &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;As for VB, not used in ArcGIS Pro any more, and I haven't used ArcMap in years, so I can't help you out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess no one else is jumping in, so I can only wish you good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2020 22:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773582#M35</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2020-04-21T22:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a new field with integer year extracted from date field in arcpy</title>
      <link>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773583#M36</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using Python, try the following in your expression:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;!inspection_date!&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;date&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;year&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can't remember the exact version, possibly 10.5.x, Esri switched from having Esri date fields returned as Python strings to Python datetime.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Apr 2020 16:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-analyse-questions/how-to-populate-a-new-field-with-integer-year/m-p/773583#M36</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-04-22T16:07:53Z</dc:date>
    </item>
  </channel>
</rss>

