I have a text field featuring a 4 digit year. How would I assign a default month and day to the year in a new date field?
ex. 2010 needs to be converted to 1/1/2010
I attempted this in the field calculator:
def dt(year):
dt_str = year
dt_obj = datetime.datetime.strptime(dt_str, '%Y')
return dt_obj
install date =
dt(!year!)
date
indatetime
with your new functiondate
. Try changing the name of your function to be something else.year
variable is an integer. Just add a line converting it --dt_str = str(year)