# Name: AddDateAttributes.py
# Description: Add fields for hour, day full name, month, day of the month,
# and year to the calls for service data based on the call date
# field.
# Import system modules
import arcpy
# Set environment settings
arcpy.env.workspace = r"C:/data/city_pd.gdb"
# Set local variables
in_features = "CallsForService"
date_field = "CALLDATE"
# Customize the name of output date attribute fields
# ["Output Time Format", "Output Field Name"]
day_name_field = ["DAY_FULL_NAME", "CALL_DAYOFWEEK"]
day_week_field = ["DAY_OF_WEEK", "CALL_DAYNUM"]
hour_field = ["HOUR", "CALL_HOUR"]
month_field = ["MONTH", "CALL_MONTH"]
day_num_field = ["DAY_OF_MONTH", "CALL_DAY"]
year_field = ["YEAR", "CALL_YEAR"]
date_attributes = [day_name_field, day_week_field, hour_field, month_field, day_num_field,
year_field]
# Execute AddDateAttributes
arcpy.ca.AddDateAttributes(in_features, date_field, date_attributes)