I am attempting to create a sign-in, sign-out program using python and mysql on a raspberry pi. I have so far successfully created a system for registering, signing in, and signing out, but am having trouble with the final component. I am trying to subtract the two separate time-stamps (signin, signout) using TIMESTAMPDIFF, and then entering this value into a separate column in the table. However, the statement I am using is not working.
employee_id = raw_input("Please enter your ID number")
minutes_calc = "INSERT INTO attendance (minutes) WHERE id = %s VALUES (TIMESTAMPDIFF(MINUTE, signin, signout))"
name | id | signin | signout | minutes |
Dr_Kerbal 123 2016-08-21 22:57:25 2016-08-21 22:59:58 NULL
You need an
update query not
UPDATE attendance SET `minutes` = TIMESTAMPDIFF(MINUTE, signin, signout);