Can't you use a BETWEEN or >= and < with two dates? If your date column is indexed, as it should be if you're using it frequently in where clauses, the overhead of DATE_FORMAT decreases substantially.
On Dec 12, 2007 3:43 PM, Adam B <[EMAIL PROTECTED]> wrote: > > > > On Dec 11, 10:55 am, "King Simon-NFHD78" <[EMAIL PROTECTED]> > wrote: > > It may not matter to you, but I wouldn't have thought this would be a > > very efficient query, because the database is going to have to call the > > DATE_FORMAT function twice for every row in your table. I would have > > thought a more efficient version would be one that asks for all rows > > between the first of one month and the first of another month > > (especially if the date column is indexed). > > > > Something like: > > > > from datetime import date > > session.query(List).filter( > > and_(List.expire >= date(2007, 12, 1), > > List.expire < date(2008, 1, 1)) > > ).all() > > > > Adding one month to a date is pretty easy, but if you wanted to do any > > more complicated date calculations, the dateutil library is very good: > > > > http://labix.org/python-dateutil > > Ah yes, was so obsessed with the solution. Letting the mysql work is > much > more efficient. It will matter under heavy load. > > I will check out dateutil, thanks. > > br > > Adam > > > > > > -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---