我输入的日期如下:
year = int(input('Enter a year'))
month = int(input('Enter a month'))
day = int(input('Enter a day'))
date1 = datetime.date(year, month, day)
print date1
date1.strftime('%year-%month-%day')
print date1
尝试了两种方法,并获得以下输出:
query_cnt = "select * from Table_name where CLOSED_DATE >
to_date(to_char(date1),'yyyy-mm-dd')
输入年份2018 输入月份8 输入一天1 2018-08-01 2018-08-01 追溯(最近一次通话): 文件“ ./closed.py”,第41行,在 cursor.execute(查询) cx_Oracle.DatabaseError:ORA-00904:“ DATE1”:无效的标识符
query_cnt = "select * from Table_name where CLOSED_DATE > to_date(:date1,'yyyy-mm-dd')
Enter a year2018
Enter a month8
Enter a day1
2018-08-01
2018-08-01
Traceback (most recent call last):
File "./closed.py", line 41, in <module>
cursor.execute(query)
cx_Oracle.DatabaseError: ORA-01008: not all variables bound
手动输入日期效果很好 query_cnt =“从表名中选择*,其中CLOSED_DATE> to_date('2018-08-01','yyyy-mm-dd')
我希望该日期成为通过python的用户输入值,请帮助