that's less of a SqlAlchemy question and more of a general database
question.
there are a handful of approaches on StackOverflow, and the easier approach
can differ across databases.
try searching for "birthdate/birthday range" and "postgresql" or "mysql" .
I'd suggest that you find one ther
Nice to start some discussion and sorry about the unclarity.
Gulli, you are spot on with your code. Thanks!
Next challange is to get all the birthdays of the next 7 days. This code
does *not *do the trick;
> members_next = Member.query.filter( \
> (extract("MONTH",
> sorry, it looks like the OP did want people born on the current
month/day/year combo.
No, you were right the first time : ) ... he wanted members whose
dateofbirth, *after changing the year to the current year*, would be today.
That amounts to equating the month and day only.
Something like thi
I think you were right in the first place. He does want to leave the year
out, hence the replace function ... Note to myself - understand the
question before you answer ...
On Wednesday, August 28, 2013 9:01:14 PM UTC+3, Jonathan Vanasco wrote:
>
> sorry, it looks like the OP did want people bor
To clarify:
- The class-level attribute Member.dateofbirth is not a date/datetime
object. It is a instrumented attribute representing a column in the
database table behind this model. So it does not have any method called
replace.
- Once you get an *instance* of Member, the instance-level attribu
sorry, it looks like the OP did want people born on the current
month/day/year combo.
you should be able to wrap all the comparisons in a date like this :
Member.query.filter( sqlalchemy.func.date(Member.dateofbirth) ==
'2013-08-27' ).all()
Member.query.filter( sqlalchemy.func.date(Memb
On Wednesday, August 28, 2013 12:52:03 PM UTC-4, herzaso wrote:
>
> What's wrong with Member.dateofbirth==datetime.today() ?
>
datetime.today() is "now" -- or "August 28, 2013 12:52:03 PM UTC-4"
The OP wants a sql operation that matches the Month+Day of Member.dateofbirth
to the Month+day of to
What's wrong with Member.dateofbirth==datetime.today() ?
On 28 Aug, 2013 7:47 PM, wrote:
> 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;
>
>
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.date