【发布时间】:2016-09-15 19:46:41
【问题描述】:
我正在尝试根据返回为 Decimal(160919, ) 的 Zoned Decimal 值过滤记录。我如何使用它来过滤日期(即:160919) 下面是我用来提取订单数据的代码:
#connect to APlus
import pyodbc
import time
import cursor as cursor
today = int(time.strftime("%y%m%d"))
whatisit = type(today)
print whatisit
cnxn = pyodbc.connect('DSN=aplus; uid=username;pwd=password')
cursor = cnxn.cursor()
query = """ select OHORNO, OHRSDT
from ORHED
where OHCSNO = 206576 and CAST(OHRSDT AS INT) = '$[today]'"""
cursor.execute(query)
row = cursor.fetchall()
if row :
print(row)
print ("Today : " + today)
【问题讨论】:
-
如果只是为了后代,请更新问题以发布表 ORHED 的字段 OHRSDT 的 DDL,以及表达式 '$[today]' 的解析值;例如通过为名为
query', as something like, and perhaps this is the effect:... 和 CAST(OHRSDT AS INT) = '160919'` 的变量的赋值提供字符串结果 注意:最好将文字选择值强制转换为匹配列,而不是其他方式 [显示],但是这是可选的,因为文字会被隐式转换。
标签: python sql ibm-midrange pyodbc db2-400