I am trying to create a Year Field so I can combine multiple datasets into one then filter them by year. The individual datasets only have the year in their name(example: table_2019). Does anyone know how I can bring the name of the table in as a value in field calculator?
AFAIK, it's not possible to get the name of the table in the Calculate Field tool. But you can throw together a litte script where you get the year from the table name and then use that to calculate a new field:
arcpy.env.workspace = "G:/ArcGIS/.../my_database.gdb"
datasets = ["TestPoints_2019", "TestPoints_2020"]
for ds in datasets:
year = ds.split("_")[-1]
arcpy.management.CalculateField(ds, "Year", year, "PYTHON3")
Thank you @JohannesLindner I will try that.