1

I need to convert the date field in the feature class. The original date format is 15-Jan-2012, 27-Apr-2012, likewise.

How can I convert it into MM/dd/yyyy format?

1

1 Answer 1

4

Use Field Calculator with Python parser. I calculate a new field but you can overwrite your original field if you want to.

def convdate(f):
    from datetime import datetime
    dobj = datetime.strptime(f, '%d-%b-%Y') #Create a datetime object
    newdate = datetime.strftime(dobj, '%m/%d/%Y') #Convert back to string in the format you ask for
    return newdate

convdate( !datefield!) #Replace datefield with the name of your existing field

enter image description here

See: https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

to understand the '%d-%b-%Y' etc.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.