I have several DataFrames that have Order_date column. In all DataFrames, the Order_date columns' dtypes are datetime64[ns]. Please note that these columns are filled with valid dates and NaT values.
An example of how Order_date column looks like when printed:
Order_date
1 2017-01-01
2 NaT
3 NaT
4 NaT
5 2017-10-22
I am trying to populate these columns of DataFrames into MS Access table via pyodbc.
I get the following error:
pyodbc.DataError: ('22008', '[22008] [Microsoft][ODBC Microsoft Access Driver]Datetime field overflow (SQLExecDirectW)')
After research, I noticed that the Date/Time datatype for MS Access 2016 corresponds with ODBC datatype SQL_TIMESTAMP.
So, I tried the following to convert datetime64[ns] to SQL_TIMESTAMP:
import datetime
cursor.execute("SQL statement...VALUES(?)", datetime.datetime(order_date))
However, I get this error: TypeError: an integer is required (got type Timestamp).
What can I do to successfully populate Pandas/Numpy datetime64[ns] values into MS Access table? How can I convert datetime64[ns] values into SQL_TIMESTAMP?