我用pydoc从sql数据库中获取数据。在
我想用WHERE语句过滤日期。我有:
cursor.execute("SELECT isnull(SOP30200.SOPNUMBE,''), isnull(SOP30200.docdate,'') from SOP30200 where SOP30200.docdate > datetime.datetime(2015,1,1,0,0)")
我得到了一个错误:
^{pr2}$没有WHERE语句,我成功地获得了数据。我确实检查了拉出的“docdate”字段的类型日期时间。日期时间. 在
EDIT:还应该指出提取的日期的格式是datetime.datetime(2013, 5, 8, 0, 0)
““日期时间。日期时间“不是SQL函数,是Python类的标准库。在
可能是:
您需要使用参数注入/插入日期。SQL server正在尝试按原样运行SQL语句,并希望数据库中存在一个
datetime.datetime(..)
函数。在请参见http://mkleehammer.github.io/pyodbc/-参数部分
相关问题 更多 >
编程相关推荐