I'm trying to make specific data entries within a week get selected, however, I'm unsure how to get my program to recognize the dates where the week would have started and ended. This is my current code for the function:
elif report_option == "C":
print("Expense Report by Week: \n")
year = int(input("Enter the year of the week's expenses you'd like to view (YYYY): \n"))
month = int(input("Enter the month the week's expenses you'd like to view (MM): \n"))
day = int(input("Enter the day the week's expenses you'd like to view (DD): \n"))
date = datetime.date(year, month, day)
c.execute("SELECT * FROM tblFinance")
conn.commit()
for row in c.fetchall():
print(row)
categories = []
amountspent = []
for row in c.execute('SELECT CategoryID, AmountSpent from tblFinance WHERE FinanceDate=?', (date,)):
print(row[0])
print(row[1])
categories.append(row[0])
amountspent.append(row[1])
plt.plot(categories, amountspent, '-')
plt.ylabel('Amount Spent')
plt.xlabel('Category ID')
plt.show()
menu()
Any help would be appreciated, thank you! EDIT: I am now trying to get a separate function working for month. However, the like function isn't going well for me! Code for month function below:
elif report_option == "D":
print("Expense Report by Month: \n")
month_input = input("Enter the year and month of the month's expenses you'd like to view (YYYY-MM): \n")
c.execute("SELECT * FROM tblFinance")
conn.commit()
for row in c.fetchall():
print(row)
categories = []
amountspent = []
for row in c.execute('SELECT CategoryID, AmountSpent from tblFinance WHERE FinanceDate LIKE ?',
(month_input, )):
print(row[0])
print(row[1])
categories.append(row[0])
amountspent.append(row[1])
plt.plot(categories, amountspent, '-')
plt.ylabel('Amount Spent')
plt.xlabel('Category ID')
plt.show()
menu()