<?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 do I change date format in labels in New to GIS Questions</title>
    <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618344#M1623</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a python function for the label expression to change your date format. Click on the Expression button on the Label properties then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select your date field.&lt;/LI&gt;&lt;LI&gt;Check the Advanced option&lt;/LI&gt;&lt;LI&gt;Change the Parser option to Python&lt;/LI&gt;&lt;LI&gt;Copy and paste the python function (below) into the expression&lt;/LI&gt;&lt;LI&gt;Change the input datetime format if required (in the example this is '%d/%m/%Y %H:%M:%S %p')&lt;/LI&gt;&lt;LI&gt;Change the output format if required (in the example this is '%d, %b %Y')&lt;/LI&gt;&lt;LI&gt;Click Verify to test and OK to apply&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;IMG alt="date-labels.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/12653_date-labels.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Python function for the label expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14108245369649587" jivemacro_uid="_14108245369649587"&gt;
&lt;P&gt;from datetime import datetime&lt;/P&gt;
&lt;P&gt;def FindLabel ( [TestDate] ):&lt;/P&gt;
&lt;P&gt;&amp;nbsp; d = datetime.strptime([TestDate], '%d/%m/%Y %H:%M:%S %p')&lt;/P&gt;
&lt;P&gt;&amp;nbsp; return d.strftime('%d, %b %Y')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A list of format strings is available here:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior" title="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior"&gt;8.1. datetime — Basic date and time types — Python 2.7.8 documentation&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owen &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.spatialxp.com.au/"&gt;Spatial XP&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Sep 2014 23:45:56 GMT</pubDate>
    <dc:creator>OwenEarley</dc:creator>
    <dc:date>2014-09-15T23:45:56Z</dc:date>
    <item>
      <title>how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618342#M1621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to label point features with a date field. The labels show long date and time. I do not want to show the time, just the date. Is there a way to format the label to show only the date?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 18:42:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618342#M1621</guid>
      <dc:creator>JamesHarrington</dc:creator>
      <dc:date>2014-09-15T18:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618343#M1622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can change date label format in the label expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBScript:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14108242544258581 jive_text_macro" jivemacro_uid="_14108242544258581"&gt;
&lt;P&gt;DateValue([date])&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the &lt;A href="http://www.w3schools.com/vbscript/vbscript_ref_functions.asp"&gt;VBScript Date functions&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Likewise, search for Python date functions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 23:39:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618343#M1622</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2014-09-15T23:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618344#M1623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a python function for the label expression to change your date format. Click on the Expression button on the Label properties then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select your date field.&lt;/LI&gt;&lt;LI&gt;Check the Advanced option&lt;/LI&gt;&lt;LI&gt;Change the Parser option to Python&lt;/LI&gt;&lt;LI&gt;Copy and paste the python function (below) into the expression&lt;/LI&gt;&lt;LI&gt;Change the input datetime format if required (in the example this is '%d/%m/%Y %H:%M:%S %p')&lt;/LI&gt;&lt;LI&gt;Change the output format if required (in the example this is '%d, %b %Y')&lt;/LI&gt;&lt;LI&gt;Click Verify to test and OK to apply&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;IMG alt="date-labels.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/12653_date-labels.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Python function for the label expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14108245369649587" jivemacro_uid="_14108245369649587"&gt;
&lt;P&gt;from datetime import datetime&lt;/P&gt;
&lt;P&gt;def FindLabel ( [TestDate] ):&lt;/P&gt;
&lt;P&gt;&amp;nbsp; d = datetime.strptime([TestDate], '%d/%m/%Y %H:%M:%S %p')&lt;/P&gt;
&lt;P&gt;&amp;nbsp; return d.strftime('%d, %b %Y')&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A list of format strings is available here:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior" title="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior"&gt;8.1. datetime — Basic date and time types — Python 2.7.8 documentation&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owen &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.spatialxp.com.au/"&gt;Spatial XP&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 23:45:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618344#M1623</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-09-15T23:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618345#M1624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately, I have some dates with times, some without. None of these solutions work without writing a much more complex script to identify the format. This is much too complicated. Why can't it recognize what format, and allow us the option to display it in whatever format we choose?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Oct 2014 15:42:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618345#M1624</guid>
      <dc:creator>JamesHarrington</dc:creator>
      <dc:date>2014-10-28T15:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618346#M1625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's say I take a date field which has values like: 7/23/2015 7:00:00 AM.&amp;nbsp; When I use the VB function TIMEVALUE to label the field it returns 7:00:00 AM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I want it to return 7 AM, how do I format the VB line?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 14:58:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618346#M1625</guid>
      <dc:creator>JasonBalmut</dc:creator>
      <dc:date>2015-07-23T14:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618347#M1626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can find a list of time format tags here: &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s900000013000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s900000013000000"&gt;ArcGIS Help 10.1&lt;/A&gt;. Essentially, you would use the tag, &lt;SPAN class="usertext"&gt;format= "h tt".&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2015 16:54:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618347#M1626</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-07-23T16:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do I change date format in labels</title>
      <link>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618348#M1627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the same question regarding displaying only the month and day of the date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a snip of the date field in ArcMap&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/435733_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from datetime import datetime &lt;BR /&gt;def FindLabel ( [StartDate] &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;d = datetime.strptime([StartDate], '%m/%d/%Y %I:%M:%S %p') &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return d.strftime('%d %m')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the error I am getting when I verify the expression.&amp;nbsp; I read &lt;A href="https://stackoverflow.com/questions/25279993/parsing-non-zero-padded-timestamps-in-python/25280059"&gt;this&lt;/A&gt;&amp;nbsp;so I know that the zero-padded date is not an issue..&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/435755_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any insight on why the error is showing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2019 19:50:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/new-to-gis-questions/how-do-i-change-date-format-in-labels/m-p/618348#M1627</guid>
      <dc:creator>BrandonLee1</dc:creator>
      <dc:date>2019-01-24T19:50:09Z</dc:date>
    </item>
  </channel>
</rss>

