0
我正在編寫一個程序,以找出今天的日期和出生日期之間的差異。我試圖用日期DIFF得到他們的年齡,但 保持返回此消息 sqlite3.OperationalError方法:近「(」:語法錯誤Python的SQL日期差異查詢
def workoutage():
print ("Current date and time: " , datetime.datetime.now())
print ("Or like this: " ,datetime.datetime.now().strftime("%Y-%m-%d"))
today = datetime.datetime.now().strftime("%Y-%m-%d")
print("the date today is ", today)
con = lite.connect(db)
cur = con.cursor()
' - DateofBirth) from Pupils"
ageQuery = "SELECT pupils.dateofBirth DATEDIFF(day, '"+today+",
pupils.dateofBirth) AS NumberOfDays from Pupils"""
cur.execute(ageQuery)
ageQueryList = cur.fetchall()
showList(ageQueryList)
非常感謝它的工作 –