Thanks Audrius,

Your answer was very helpful, is exactly what I was looking.


2012/12/17 Audrius Kažukauskas <audr...@neutrino.lt>

> On Mon, 2012-12-17 at 11:54:20 -0800, Gabriel Pozo wrote:
> > I am a new user of sqlalchemy, I need to know how I can filter the
> > weekdays, to exclude Saturdays and Sundays.
> > I look for something similar to the function dayofweek of MySQL.
>
> In SQLAchemy you can refer to DB functions via func[0] construct.  Say,
> you have the following model:
>
>   class Model(Base):
>       __tablename__ = 'foo'
>       id = Column(Integer, primary_key=True)
>       date = Column(DateTime)
>
> You can query it like this:
>
>   session.query(Model).filter(
>       # 1 = Sunday, 2 = Monday, ..., 7 = Saturday.
>       func.dayofweek(Model.date).between(2, 6)
>   ).all()
>
> [0]
> http://docs.sqlalchemy.org/en/rel_0_8/core/expression_api.html#sqlalchemy.sql.expression.func
>
> --
> Audrius Kažukauskas
> http://neutrino.lt/
>



-- 
*Saludos, Gabriel*

http://aprendiendodeandroidymas.com/<http://aprendiendodeandroidymas.blogspot.com.ar/>

http://culturalibrerosario.org/

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to