fixed error of using the wrong prepared statements, and updated to automatically get the datetime