I tried to copy a field with dates that had type 'TEXT' to a new column of type 'DATE' because it is not possible to change the initial type of the original field.


The initial field has all rows with data but it gives this error:

'Empty value for Objectid = 0'

And it can't copy anything to the other field.

  • 1
    select the ones where the date field isn't empty for a start then read up on calculating dates from strings (eg community.esri.com/thread/22042), I would use a python parser instead of omitting the parser and defaulting to VBscript, dates are a little bit special so to help much more we would need to know what storage type your feature class is (OBJECTID means geodatabase, it's 0 not o as OBJECTID is numeric, but enterprise, file and personal geodatabases have their own quirks). – Michael Stimson Nov 21 '18 at 8:01
  • @user10680652 I would rather use arcpy.da.UpdateCursor(). Here you can convert your string data into date format. – Pavel Pereverzev Nov 22 '18 at 11:05
  • Can you add a screenshot showing the attribute table where the text field with the "dates" are visible? – BERA Nov 23 '18 at 8:14

You need to convert your text into a datetime format. So using the datetime.strptime method, you have to decipher what your text date looks like, and convert that into a datetime format.

Using the UpdateCursor, you can search for your string date, convert that into a datetime object, then update the new field with the correct date object.

Please see link for more information on the DateTime python module.

For example:

import datetime

string_date = "23/11/18 12:30"

string_date_into_datetime = datetime.datetime.strptime(string_date, "%d/%m/%y %H:%M")

print string_date_into_datetime 
| improve this answer | |
  • tried turning 15/01/2015 with YYYY/MM/dd in arcpy and turned to 15/Jan/2015. How to turn it to as it was with 01 instead of Jan? – user10680652 Nov 23 '18 at 10:29
  • Use %m instead of %b – PhilippNagel May 24 '19 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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