user3286703
user3286703

Reputation: 41

SQLAlchemy how to check if a value is between the values in two columns?

How can I check if the condition value is between column1 and column2?

MySQL:

select
    *
from
    tablename
where
    '2014-01-01' between start_date and end_date

SQLAlchemy:

select(
  [table.c.id],
  and_('2014-01-01'.between(start_date, end_date))
)

is it possible ?

Upvotes: 2

Views: 588

Answers (1)

zzzeek
zzzeek

Reputation: 75207

from sqlalchemy import literal

literal('2014-01-01').between(x, y)

Upvotes: 3

Related Questions