AnsweredAssumed Answered

Update date field

Question asked by laura_busolo@redlands.edu_univredlands on Jan 29, 2018
Latest reply on Jan 30, 2018 by rvburton

I'm pretty new to python and I have a table in a geodatabase that contains info on data sources, names, targets and a date field. I have a script that copies features based on a user's input, e.g. if ft_ID ==1. then copy features. I want to update the date field based on the affected/copied features row that the "copy features" was executed, and I don't know how to. (e/g. If I copy feature with ID as "1", update the corresponding date field for today/whatever day I copy that field). I just know I may need to use an update cursor.


I was playing around with the update cursor, but only got it to work to update current date for all features. This is how it looks like so far.


LYR_UPDATE_TABLE = r".\...gdb\Layer_Update"
#FIELD_NAMES = ['a', 'b', 'c',  'LastUpdate']
fld = 'LastUpdate'
btch_num = raw_input ("Please enter ID: ")

with arcpy.da.UpdateCursor (LYR_UPDATE_TABLE, fld) as dt_cursor:
   for row in dt_cursor:
      # btch_id was defined earlier as the user's input to choose the features to cpy from the table
      if batch_id == int(btch_num):
      #Update the LastUpdate field with the date of the copy features-update
      """row [6] = (...)"""
      print ('date Update Success!')