<?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: Convert Date attribute to Quarter in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-date-attribute-to-quarter/m-p/174913#M13464</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In attribute table create new integer Quarter field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In Field Calculator choose Python parser and try a code which calculates quarter number based on month number:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;(int(!Date![:2])-1)//3+1&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Mar 2012 10:52:14 GMT</pubDate>
    <dc:creator>MarcinGasior</dc:creator>
    <dc:date>2012-03-15T10:52:14Z</dc:date>
    <item>
      <title>Convert Date attribute to Quarter</title>
      <link>https://community.esri.com/t5/python-questions/convert-date-attribute-to-quarter/m-p/174912#M13463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have feature classes have "Date" fields in date format and some of them are in String.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to convert them to Quarter and this is what i wrote...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;please comments what parts got wrong and if anyone has better idea for codes, please let me know&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: Calculate Field&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TESTING = if "Date" &amp;lt;= 03/31/2000 then 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if "Date" &amp;gt;= 04/01/2000 and "Date" &amp;lt;= 06/30/2000 then 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if "Date" &amp;gt;= 07/01/2000 and "Date" &amp;lt;= 09/30/2000 then 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management(Input_Feature, "Quarter", TESTING, "PYTHON", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and what if i have years thru 2000 - 2010 and want to convert them once, how do i code it ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or is there way that i can only use the month and date and ..process for another years?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 08:51:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-date-attribute-to-quarter/m-p/174912#M13463</guid>
      <dc:creator>PilKwon</dc:creator>
      <dc:date>2012-03-15T08:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date attribute to Quarter</title>
      <link>https://community.esri.com/t5/python-questions/convert-date-attribute-to-quarter/m-p/174913#M13464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In attribute table create new integer Quarter field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In Field Calculator choose Python parser and try a code which calculates quarter number based on month number:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;(int(!Date![:2])-1)//3+1&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 10:52:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-date-attribute-to-quarter/m-p/174913#M13464</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2012-03-15T10:52:14Z</dc:date>
    </item>
  </channel>
</rss>

