You can try:
from sqlalchemy import between, text, func
birthdateCamp = func.extract('month', dateofbirth) * text('100') +
func.extract('day', dateofbirth)
datefrom = today.month * 100 + today.day
dateto = tomorrow.month * 100 + tomorrow.day
query.filter(between(birthdateCamp, datefrom, dateto))
Em quarta-feira, 28 de agosto de 2013 13:47:20 UTC-3, [email protected]
escreveu:
>
> Hi,
>
> I want to retrieve all the people who are born at today's date. I'm using
> Flask with sqlalchemy;
>
> class Member(db.Model):
>>
> ...
>
> dateofbirth = Column(Date)
> ...
>
>
> In my view.py;
>
>> from datetime import date, timedelta
>>
> today = date.today()
>>
> members_today =
> Member.query.filter(Member.dateofbirth.replace(year=today.year) ==
> today).all()
>>
>>
> But I receive this error;
>
>> AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator'
>> object associated with Member.dateofbirth has an attribute 'replace'
>>
>
> Anyone has an idea?
>
> Thanks
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.