So I was wondering if there is a way to get a week or month period from DB. I have in my DB a value
and a date
and I want to get all items that their date are between for example 2020-03-01
and 2020-04-01
.
I tried the following code but it gives a warning and doesn't return nothing:
The code:
users_count = StatsUsers.query.filter(and_(func.date(StatsUsers.created_date >= '2020-03-30'), func.date(StatsUsers.created_date <= '2020-04-30')))
for x in users_count:
print(x.value)
return render_template('admin/index.html', users_count=0)
The warning that it gives:
Warning: (1292, "Incorrect datetime value: '1'")
My DB: