Omer H
Omer H

Reputation: 435

Extract a weekday() from an SQLAlchemy InstrumentedAttribute (Column type is datetime)

I have an SQLAlchemy DB column which is of type datetime:

type(<my_object>) --> sqlalchemy.orm.attributes.InstrumentedAttribute

How do I reach the actual date in order to filter the DB by weekday() ?

Upvotes: 5

Views: 5309

Answers (1)

Omer H
Omer H

Reputation: 435

I got it: from sqlalchemy import func (func.extract(<my_object>, 'dow') == some_day)

dow stands for 'day of week' The extract is an SQLAlchemy function allowing the extraction of any field from the column object.

Upvotes: 7

Related Questions