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

Using sqlalchemy, resp. flask_sqlalchemy and sqlite I would like to query all rows which have the date field from last week. Best would even be where the date column values are in a certain week of the year:

  • reporting_date = db.Column(db.Date, nullable=False, index=True)

thinking of something like (pseudo code):

  • found_rows = Table.query.filter_by(strftime('%W',reporting_date)==7).all()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source