<?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 Field Calculator - DateDiff() function Python Equivalent in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369689#M29223</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have a model that calculates an integer field with the DateDiff() function.&amp;nbsp; The difference is between an 'expiry_date'(date type) field formatted "mm/dd/yyyy" and the now() function.&amp;nbsp; I want to export this model to a Python script, however it wont allow the VB function to be used.&amp;nbsp; It is a large model that I would rather not rewrite, is there python code that I can use in the tool before I export it to a python script in place of the VB to calculate this integer field??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Oct 2014 18:25:58 GMT</pubDate>
    <dc:creator>NickMoylan</dc:creator>
    <dc:date>2014-10-03T18:25:58Z</dc:date>
    <item>
      <title>Field Calculator - DateDiff() function Python Equivalent</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369689#M29223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have a model that calculates an integer field with the DateDiff() function.&amp;nbsp; The difference is between an 'expiry_date'(date type) field formatted "mm/dd/yyyy" and the now() function.&amp;nbsp; I want to export this model to a Python script, however it wont allow the VB function to be used.&amp;nbsp; It is a large model that I would rather not rewrite, is there python code that I can use in the tool before I export it to a python script in place of the VB to calculate this integer field??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 18:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369689#M29223</guid>
      <dc:creator>NickMoylan</dc:creator>
      <dc:date>2014-10-03T18:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator - DateDiff() function Python Equivalent</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369690#M29224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the &lt;A href="https://docs.python.org/2.7/library/datetime.html#datetime.datetime.strptime"&gt;datetime module&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code block:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14125467935848532 jive_text_macro" jivemacro_uid="_14125467935848532"&gt;
&lt;P&gt;import datetime&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expression:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14125468384973986 jive_text_macro" jivemacro_uid="_14125468384973986"&gt;
&lt;P&gt;(datetime.datetime.now() - datetime.datetime.strptime(!field_with_formatted_date!, "%m/%d/%Y")).days&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Oct 2014 22:07:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369690#M29224</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-10-05T22:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: Field Calculator - DateDiff() function Python Equivalent</title>
      <link>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369691#M29225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This works great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks foir the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 18:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-calculator-datediff-function-python/m-p/369691#M29225</guid>
      <dc:creator>NickMoylan</dc:creator>
      <dc:date>2014-10-06T18:23:06Z</dc:date>
    </item>
  </channel>
</rss>

