Inserting datetime into a MS SQL table using pyodbc
问题 I'm trying to insert a datetime value into a MS SQL Server table using pyodbc. If I do it manually, something like: cursor.execute("""insert into currentvalue(value1,currentdatetime) values(55,'2014-06-27 16:42:48.533')""") I have no problem at all, but when I try to do: currenttime = str(datetime.datetime.now()) cursor.execute("""insert into currentvalue(value1,currentdatetime) values(55,"""+ currenttime+")") I got this error: SQL server Incorrect syntax near '07' which i think is the number