I am writing code that will add staff shifts into a shift schedule. the part I am trying to get to work is one that adds shifts in that recur every week (ie work every Monday at 5). I thought I had a good way of doing it until I started getting error messages regarding the datatype. I am new to the datetime module so I apologise if there is a simple explanation
here is the relevant part of my code:
def addWeekly(STAFFID,SDAY,SMONTH,SYEAR,STARTTIME,ENDTIME):
DATE = datetime.date(SYEAR, SMONTH, SDAY)
conn = sqlite3.connect('test.db')
cursor = conn.cursor()
count = 0
for records in cursor:
count += 1
SHIFTID = count
for i in range(100):
cursor.execute('INSERT INTO SHIFT VALUES (?,?,?,?,?)',
(SHIFTID,STAFFID,DATE,STARTTIME,ENDTIME))
DATE += timedelta(days=7)
and here is the error:
Traceback (most recent call last):
File "C:/Users/360491/Documents/Coursework/Prototypes/calendar fix.py", line 36, in <module>
addWeekly(STAFFID,SDAY,SMONTH,SYEAR,STARTTIME,ENDTIME)
File "C:/Users/360491/Documents/Coursework/Prototypes/calendar fix.py", line 16, in addWeekly
DATE = datetime.date(SYEAR, SMONTH, SDAY)
TypeError: descriptor 'date' requires a 'datetime.datetime' object but received a 'str'
i have tried using integers. any help would be greatly appreciated
SYEAR, SMONTH, SDAYare integers?