使用(Flask)SQLAlchemy 在日期中查找具有特定周数的行

Find rows having a certain Week Number in a date using (Flask) SQLAlchemy

分别使用 sqlalchemy flask_sqlalchemy和sqlite我想查询 所有具有上周日期字段的行。最好的甚至是 日期列值在一年中的某个星期:

想像(伪代码):

解决了我的问题。 我的伪代码几乎是正确的,所以这里是工作语句:

from sqlalchemy import func
DailyReportItem.query.filter(func.strftime('%W',DailyReportItem.reporting_date)=="07").all()

wich,在 sqlite 中转换为以下内容:

SELECT *
FROM daily_reports
WHERE strftime(?, daily_reports.reporting_date) = ?
('%W', '07')

问题基本上只是周数有前导零并且是字符串