TIMEDIFF and SQLAlchemy

1,519 views
Skip to first unread message

Christian Démolis

unread,
Nov 17, 2010, 6:06:29 AM11/17/10
to sqlal...@googlegroups.com
Hi,

Do you know how to do this query with sqlalchemy?

SELECT
Id,  TIMEDIFF( End, Start)
FROM
plage
WHERE
TIMEDIFF(End,Start)>=TIME('02:20:00');


In my model, Start and End are DateTime
Start = Column('Start', DateTime)
End = Column('End', DateTime)

akm

unread,
Nov 17, 2010, 8:30:00 AM11/17/10
to sqlal...@googlegroups.com
Try this:

from sqlalchemy import func
from sqlalchemy.sql import select

s = select( [Plage.Id,
func.timediff(Plage.Start, Plage.Start)
],
(func.timediff(Plage.Start, Plage.Start) >= func.time('02:20:00'))
)


Thanks,
--
Abdul Kader M

> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>

Christian Démolis

unread,
Nov 18, 2010, 3:34:30 AM11/18/10
to sqlal...@googlegroups.com
It works!

Thx

2010/11/17 akm <akm....@gmail.com>
Reply all
Reply to author
Forward
0 new messages