I am trying to use an expression to convert my date field to a simple %d,%b,%Y format. Right now it is in "%Y%m%d %H:%M:%S %z"
How do I do it properly using Python to do this in ArcGIS Pro?
Q&As from ArcMap have given me errors.
My labels are coming from my [Date] field.
Here's one example of a code I tried –
def FindLabel ( [Date] ):
return str(datetime.datetime.strptime([Date],"%Y/%m/%d %H:%M:%S %z").date())
and I got this error:
My labels look this :
I also tried this code:
from datetime import datetime
def FindLabel ( [Date] ):
d = datetime.strptime([Date], '%Y/%m/%d %H:%M:%S %z')
return d.strftime('%d, %b %Y')
Best Answer
It might be a bit late but just in case you still have the same issue, the Python code I used was the following:
You could change the field "Fecha" for "date", I used it that way cause my fields are in Spanish.