Here is model:
class User(Base):
...
birthday = Column(Date, index=True) #in database it's like '1987-01-17'
...
I want to filter between two dates, for example to choose all users in interval 18-30 years.
How to implement it with SQLAlchemy?
I think of:
query = DBSession.query(User).filter(
and_(User.birthday >= '1988-01-17', User.birthday <= '1985-01-17')
)
# means age >= 24 and age <= 27
I know this is not correct, but how to do correct?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…