How to convert date, which is in text formated field to date formated field?
Also, there is dates which have only year, without days and months and empty fields.
I've tried Convert Time Field. But it gave me
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
You can use strptime but it is probably easier to use pandas.to_datetime to convert the strings to datetimes. It is smarter/more flexible and can handle different string formats. Add a date field, create a function in Field Calculator or use da.UpdateCursor:
import arcpy import pandas as pd table = r'C:\folder\Default.gdb\datedata' #Change to match your data fields = ['somedateasstring','datefield'] #Change to match your data with arcpy.da.UpdateCursor(table, fields) as cursor: for row in cursor: row = pd.to_datetime(row, errors='coerce') #Rows that cant be converted to date will be set to None with errors='coerce' cursor.updateRow(row)