More and Better Examples of Label Expressions Using Python in ArcGIS

473
1
07-16-2014 09:52 AM
Status: In Product Plan
Labels (1)
RolandShield
New Contributor II

I want to use Python rather than VBScript to label items for various reasons. However, Python is proving to be very, very finicky in regards to syntax and context, relative to VBScript.

An example: in order to show labels of a date stamp in the "mm/dd/yyyy" format using VBScript, you simply apply the following code:  FormatDateTime(d,2)  Yes, that is it!

However, I have tried in many, many ways to accomplish the same thing using Python---for hours. And no success.
So I called tech. support and they don't know either. So they are going to "explore the idea" and get back to me.
Meanwhile, I asked them why there are not more expamples in the ESRI Resources Help [ http://resources.arcgis.com/en/help/main/10.1/index.html#//00s800000027000000 ] regarding, for instance, date labels and they suggested that I submit that "idea" (complaint?) here.

1 Comment
WendyHarrison
Status changed to: In Product Plan

Thanks Roland

I'll add something to the documentation topic

 

def FindLabel ( [created_date] 😞
return str(datetime.datetime.strptime([created_date],"%m/%d/%Y %H:%M:%S %p").date())

 

-Wendy