简体   繁体   中英

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() ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM