I don't really get what's going on. What is Timestamp? You're querying Attendance but it seems not doing anything with it. Except you're overwriting Attendance (class) by the result of the query; you should really probably call it attendance = ....