1

Basically my problem is the opposite of Transforming ArcGIS date field to integer?

I have an integer field of year values (2005,2006,...)

I want to create a date field that has the value of that integer field as a year (I don't care if it is 1-1-2006). I just want the year correct.

How can I do it manually, and this shapefile has almost 7000 rows?

Is this possible?

1
  • 2
    Not only is it possible, it's under a dozen lines of ArcPy code in any of the several ways it could be done.
    – Vince
    Commented May 14, 2020 at 21:53

1 Answer 1

2

This is a one-liner in the field calculator. Assuming you have an integer field containing the year, and another field to populate which is a date field you can follow the below example.

In my example, the year is stored in an integer field called "Created_Year" and the date field is just called "Created".

enter image description here

In the attribute table, right click on Created and select Field Calculator.

enter image description here

Set the parser to Python and type in the following:

time.strftime('01/01/!Created_Year!')

enter image description here

The results are:

enter image description here

Your Answer

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

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