1

I have dates in my attribute table that are stored as strings - they look like 02/22/2012 (mm/dd/yyyy) - and I would like to convert them to Date type. When I try to input a custom date format in the Convert Time Field geoprocessing tool it returns in all the records and I am not sure what I am doing wrong. I've tried MM/dd/yyyy and MMddyyyy - is there something I'm missing about setting up a custom date format? Or, is there another way I can do this?

3 Answers 3

3

I created a shapefile with a string field with dates in the 02/22/2012 format and was able to convert it using the "Convert Time Field" tool after a couple tries. On my successful attempt I created a new field of type date and then ran the date conversion tool. For the custom format I used "MM/dd/yyyy". I also specified the newly created date field as the output time field. I checked the method with errors in the strings and even a string like "2/5/12" was converted to 2/5/2012. (My initial failures came because I assumed the tool would create a new date field for me, that didn't happen during my test.)

I hope this helps.

1
  • Thank you AtlasSteve - I tried this first (creating a new empty field with date type) and it appears to have worked!
    – elCo
    Feb 16, 2012 at 16:50
2

I just tested this and MM/dd/yyyy worked okay for me. Is it possible that there is a value in your string field that is not in this format? Maybe there are one or two records hiding in your string field with something like '2/22/2012' instead of '02/22/2012'.

1
  • 1
    MM/dd/yyyy worked for me too - Cyrus' suggestion of checking your string field for rows that don't match the expected format seems sensible - could be worth testing on a table with just one or two rows if you have not already done so - and maybe "breaking" the format of a row to see what that does to the expected output
    – PolyGeo
    Feb 10, 2012 at 23:07
1

I have been able to do this using ArcGIS 10.2.

When I run the Convert Time Field tool on a GDB table of 20000 rows, it says it has completed successfully but no values are updated in the target field (nulls).

However, if I run it after first selecting all the records in the table (obviously you need to be in ArcMap to do this), then it updates the values as expected!

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.