I'm trying to work out how to filter by a day in a date field. If I have a date of birth field, how do I get every person that has a birthday on the 24th on all the months?
The extract()
function creates an appropriate EXTRACT(field FROM expr)
expression for the database engine in use. Extract the day
field from the column and compare it to your day value.
session.query(Person).filter(extract('day', Person.birthdate) == 24).all()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With