<?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 DateTime field to Date in Label Expression in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461203#M5035</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm...I tried for way too long to use python.&amp;nbsp; Switched to VBScript parser and got what I wanted in a few minutes using FormatDateTime([field],2)...like what is shown in the idea above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 20:32:31 GMT</pubDate>
    <dc:creator>mpboyle</dc:creator>
    <dc:date>2014-10-30T20:32:31Z</dc:date>
    <item>
      <title>Convert DateTime field to Date in Label Expression</title>
      <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461201#M5033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;I have a DateTime field (ex: CreatedDate) and would like to only show the date with the label. How would I setup the label expression to do this using python?&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 14px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: rgba(248, 248, 248, 0.6);"&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 15:32:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461201#M5033</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2014-10-30T15:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DateTime field to Date in Label Expression</title>
      <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461202#M5034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems there is no idea how to do that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://ideas.arcgis.com/ideaView?id=087E00000005ESkIAM#sthash.PIA6XjOz" title="http://ideas.arcgis.com/ideaView?id=087E00000005ESkIAM#sthash.PIA6XjOz"&gt;ArcGIS Idea - More and Better Examples of Label Expressions Using Python in ArcGIS&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 19:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461202#M5034</guid>
      <dc:creator>Marco_AlejandroBonilla</dc:creator>
      <dc:date>2014-10-30T19:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DateTime field to Date in Label Expression</title>
      <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461203#M5035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm...I tried for way too long to use python.&amp;nbsp; Switched to VBScript parser and got what I wanted in a few minutes using FormatDateTime([field],2)...like what is shown in the idea above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 20:32:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461203#M5035</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2014-10-30T20:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DateTime field to Date in Label Expression</title>
      <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461204#M5036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot use VBScript expressions if you are publishing to ArcGIS Server.&amp;nbsp; I ran into this problem, and the key to understanding it is found in the first sentence of the third paragraph of the "Building label expressions" help topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Field values are automatically cast to text strings."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nonetheless, Python expressions are awkward for parsing strings because you can't use square brackets .&amp;nbsp; For example, in the following expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[DATEFIELD].split(" ")[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the parser will look for a field called "0" and fail.&amp;nbsp; Instead, you can use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[DATEFIELD].split(" ").pop(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a field is nullable, then you need to be prepared to handle a null value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def FindLabel ([DATEFIELD]):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; s = [DATEFIELD]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if s is None:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return None&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return s.split(" ").pop(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, label performance is adversely affected by using a function, which in turn affects the return time on an ArcGIS Server map service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[BTW, if you look at the examples, the most appropriate ones for parsing strings are in JScript, and that is probably the better route to take.]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 18:41:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461204#M5036</guid>
      <dc:creator>MarkCederholm</dc:creator>
      <dc:date>2015-05-28T18:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert DateTime field to Date in Label Expression</title>
      <link>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461205#M5037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This article &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s00000018000000" title="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//005s00000018000000" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS Desktop &lt;/A&gt; explains date fields it may help. I was able to use below to pull the date.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def FindLabel ( [LASTUPDATE] ):
&amp;nbsp; d = [LASTUPDATE] 
&amp;nbsp; a = d.split(" ")
&amp;nbsp; return a[0]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/convert-datetime-field-to-date-in-label-expression/m-p/461205#M5037</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T20:31:02Z</dc:date>
    </item>
  </channel>
</rss>

