AnsweredAssumed Answered

How to test if a date is null

Question asked by DanEvans83 on Jan 15, 2015
Latest reply on Jan 15, 2015 by DanEvans83

I am writing a python script geoprocessing tool and need to use an UpdateCursor to populate a text field with either 'Y' or 'N' depending on whether a date field is null or not. Here is my code:


with arcpy.da.UpdateCursor(arcpy.env.scratchGDB + r"/cn42n_table", (cn42n_status_field_validated, cn42n_cancel_date_field_validated, "CANC", "PARC")) as cursor:
  for row in cursor:
       if "CANC" in row[0] or not row[1] is None:
            row[2] = "Y"
            row[2] = "N"

       if "PARC" in row[0]:
            row[3] = "Y"
            row[3] = "N"

I have tried several ways of checking if row[1] (my date field) is not null but whatever I try the 'CANC' field is populated with a 'Y'.


Could someone please tell me the correct way to do this?