I have an attribute I would like to label on my map that has dates in mm/dd/yyyy format. When I label the map, it displays in that format (as one would expect). I want to draw the labels in a different format, specifically mmm yyyy or mmm yy format. I can get a dynamic text box to update with the date on the map, but I want a map to populate with project dates over the features. Thanks in advance!
Solved! Go to Solution.
What are you working with - Desktop 10.x, Pro, AGOL ? With Desktop for example, the label manager allows for creating an expression. Python code would be something like (note: advanced checked):
from datetime import datetime
def FindLabel ( [EditDate] ):
ds = datetime.strptime([EditDate], '%m/%d/%Y %H:%M:%S %p')
return ds.strftime("%B %Y")
What are you working with - Desktop 10.x, Pro, AGOL ? With Desktop for example, the label manager allows for creating an expression. Python code would be something like (note: advanced checked):
from datetime import datetime
def FindLabel ( [EditDate] ):
ds = datetime.strptime([EditDate], '%m/%d/%Y %H:%M:%S %p')
return ds.strftime("%B %Y")
Randy,
Thank you SO much! (FYI I am using ArcGIS Pro.) This was pretty much exactly what I needed! I only needed to edit two things, but this was the final leg I needed to get it working correctly!
In case you were wondering, I had two fields I wanted displayed (a project name and start date) so I added "[proj_name] + '\n' +" before the ds.strftime (%b %y) expression. And my time attribute apparently ONLY has mm/dd/yyyy so it errored-out until I removed the timegroup and timezone from the strptime function. (Also as above, I only wanted the mmm and yy, so I made the minor change to the strftime function.
This was really wracking my brain. Thanks again!
Dale