That query looks weird.
I'd suggest converting everything to a date in the database and having the
db sort it --
on postgres it would look like this --
create table test_date ( id serial primary key not null , yyyy int , mm int
, dd int );
select *
from
test_date
where
( to_date(yyyy||'-'||mm||'-'||dd,'yyyy-mm-dd') <
to_date('2013-01-01','yyyy-mm-dd') )
and
( to_date(yyyy||'-'||mm||'-'||dd,'yyyy-mm-dd') >
to_date('2012-01-01','yyyy-mm-dd') )
;
it would be different on other databases, usually similar though.
When I've had to store dates like you did, I usually store a real date in
addition, so my sql statements aren't so damn messy. storage is relatively
cheap, and having a real datetime in the database makes selects so much
faster than computed options.
create table better_date(
real_date date ,
yyyy INT,
mm INT,
dd INT,
)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.