@AlfredBaldenweck I think you are right about my project layer variable being a feature class and not a layer object - the data type for that Project_Layer variable is a "File Geodatabase Feature Class." I've tried to incorporate your code into my script tool, but I'm getting the same result. I must be missing something. When I enter this code into ArcGIS Pro python window one line at a time, it works, but when I run it as the script tool it still calculates all (selected and unselected) records.
I'm putting all of the code this time. Here are some notes for context:
The input parameter (Data Type = Feature Layer) of the script tool is to be an existing Project Layer that has a symbology field with unique values. The symbology field needs to be updated over time relative to the current date. So, as time goes on, I want to be able to automate this process. Also... the layer's current date field is actually a text field, so I add a new "Date Only" field and calculate it equal to that "text-date" field. But, of course, the main core issue I'm having is the last calculate field process applying to the entire layer/feature class and not the selected records.
import arcpy
def UpdateSymbology():
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = True
# Model Environment Setting
aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
Projects = arcpy.GetParameterAsText(0) # Input parameter
Projects_Layer = mp.listLayers(Projects)[0]
# Process: Add Field to Projects layer that is Date Only type (Add Field) (management)
Projects_Layer_1 = arcpy.management.AddField(in_table=Projects_Layer, field_name="Date", field_type="DATEONLY", field_alias="Date")
# Process: Calculate added Date Only field equal to the exisiting 'Start Date' text field (Calculate Field) (management)
Projects_Layer_2 = arcpy.management.CalculateField(in_table=Projects_Layer_1, field="Date", expression="!Start_Date!")
# Process: Select Layer By Date And Time (Select Layer By Date And Time) (ca)
Projects_Layer_3, Row_Count = arcpy.ca.SelectLayerByDateAndTime(in_layer_or_view=Projects_Layer_2, selection_type="NEW_SELECTION", time_type="SINGLE_TIME_FIELD", date_field="Date", selection_options=["DATE"], date_selection_type="DATE_RANGE", start_date=StartDate, end_date=EndDate)
# Process: Calculate Field with Selection to "Beyond 90" (Calculate Field) (management)
Projects_Layer_4 = arcpy.management.CalculateField(in_table=Projects_Layer_3, field="Symbology", expression="\"Beyond 90\"")
if __name__ == '__main__':
UpdateSymbology_()
print("FIN")