Hey everyone,
I have a dataset that has a field in the attribute table that contains datetime information. I am writing a script that selects three layers, copies them, delete extra fields and then exports the tables to an excel file. Everything I have written works correctly but the last bit is what I cannot figure out. The excel file name needs to end with the date the data was last updated.
Currently in the attribute table there is a field called dataload_date which contains datetime information for when it was last updated. using this code:
field = "dataload_date"
testlist = []
with arcpy.da.SearchCursor(FeatureClass, field) as cursor:
for row in cursor:
testlist.append(str(row[0])[0:10])
print(testlist[0])
This prints out the the date like this 2024-01-31, I need this as a string so I can manipulate it into the correct format for my file name.
I am under the impression that this code is only supposed to access the first row and append that value as a string to position 0 of test list. But it appears it iterates through every row in the dataset and appends it to position 0.

What am I doing wrong?
Code Sample came from: https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm