<?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: normalize date in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429814#M33784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try using None instead of NULL in your python code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See this python documentation on the null object: &lt;/SPAN&gt;&lt;A href="http://docs.python.org/release/2.5.2/lib/bltin-null-object.html"&gt;http://docs.python.org/release/2.5.2/lib/bltin-null-object.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Nov 2011 09:21:33 GMT</pubDate>
    <dc:creator>AndrewChapkowski</dc:creator>
    <dc:date>2011-11-04T09:21:33Z</dc:date>
    <item>
      <title>normalize date in python</title>
      <link>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429813#M33783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My Management has directed that I normalize some of our tables. So I have to add some new fields.&amp;nbsp; OK done.&amp;nbsp; One of the new fields is Incident_date.&amp;nbsp; Well&amp;nbsp; existing is a field called report date.&amp;nbsp; About half of those fields are NULL.&amp;nbsp; There is also a field call create_date. So what I want to do is if the report date has data I want to use that, if not then I want to use create_date.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I fired up calculate field. Selected the table and selected Incident as the field.&amp;nbsp; Clicked on Python, and entered:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def CalIncident(Repdat, CrteDat):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; if ( Repdat == NULL) :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return CrtDat&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Repdat&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Other window&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ReportDate =&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CalIncident(!ReportDate!, !CreateDate!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't think it understands NULL in this context.&amp;nbsp; Any idea what I should use?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2011 00:31:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429813#M33783</guid>
      <dc:creator>WilliamIde</dc:creator>
      <dc:date>2011-11-04T00:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: normalize date in python</title>
      <link>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429814#M33784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try using None instead of NULL in your python code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See this python documentation on the null object: &lt;/SPAN&gt;&lt;A href="http://docs.python.org/release/2.5.2/lib/bltin-null-object.html"&gt;http://docs.python.org/release/2.5.2/lib/bltin-null-object.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2011 09:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429814#M33784</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-11-04T09:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: normalize date in python</title>
      <link>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429815#M33785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First you forgot : behind else, maybe this is your error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this isn't the problem I think it could work if you just test if Repdat is true:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (Repdat): return CrtDat
else: return Repdat&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Or you can try the other way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if len(Repdat)&amp;gt;0: return Repdat
else: return CrtDat&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/normalize-date-in-python/m-p/429815#M33785</guid>
      <dc:creator>benk</dc:creator>
      <dc:date>2021-12-11T19:19:52Z</dc:date>
    </item>
  </channel>
</rss>

