Hello,
Based on my dataset, I have to apply a flag into a text field. This flag is derived by first looking at an ID field called SID (text), and determining the first two characters of it. Based on those 2 characters, it then looks at a date field called FullDateTime, and assigns the flag value if the time in FullDateTime falls within a specific range. Problem is, my code is not accepted by the field calculator in ArcPro 2.4:
AttendanceFlag =
DetermineAttendance (!SchoolAttendance!)
from datetime import datetime
def DetermineAttendance(SchoolAttendance):
SchoolID = SID[:2] # variable to examine leftmost 2 characters in the SID field
If DayType == “Weekend”:
SchoolAttendance = “Weekend”
Else:
If SchoolID == “RL”:
If FullDateTime.time() > = 8:55 AM and FullDateTime.time() <= 3:30 PM:
SchoolAttendance = “InSchool”
Else:
SchoolAttendance = “OutSchool”
Else:
If FullDateTime.time() > = 9:10 AM and FullDateTime.time() <= 3:45 PM:
SchoolAttendance = “InSchool”
Else:
SchoolAttendance = “OutSchool”
This is my fields setup (DaysSeconds has been changed to a text field called AttendanceFlag:
