Currently I am trying to use the field calculator to generate the most recent date values out of four fields into one field. I attempted to use the max function to calculate the most recent dates but the calculator doesn't seem to be reading the values as dates. For an example, if I have a date that reads 12/9/2016 and one that reads 7/20/2017, the field calculator chooses the first date because it reads the 9 (in the 12/9/2016 date) over the 20 (in the 7/20/2017 date) as the max. The case seems to be that the field calculator doesn't read the values as dates.

Any possible python codes for the codeblock to solve this issue? I'm thinking the datetime function is necessary in this case?

  • Are all of the fields with dates defined as Date fields or text fields? What format is the source file .shp, FGDB, GDB, etc
    – Chris M
    Jul 14, 2017 at 19:30
  • @ChrisM All fields are Date type fields. The format of the layer being used is a feature class of a GDB.
    – user99280
    Jul 14, 2017 at 19:34
  • 1
    Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. This question has been asked already and has an answer. Please see the previous Q&A linked above.
    – Midavalo
    Jul 14, 2017 at 19:39
  • @Midavalo I attempted the 'dtmax' code you suggested in the other post regarding using the max function to generate the most recent date into the new field. It failed to process the calculation.
    – user99280
    Jul 14, 2017 at 20:55
  • 1
    @Ed102089 What did it do? Any errors? How are your dates formatted in your field? All the code is doing is forcing the field calculator to see the values as actual dates (as you say in your question that the field calculator isn't doing that by default) and then using the max function same as you were trying. So if it doesn't work it's possibly due to your date format not matching the one in the code.
    – Midavalo
    Jul 14, 2017 at 20:59


Browse other questions tagged or ask your own question.