On 9/6/07, Pedro Algarvio, aka, s0undt3ch <[EMAIL PROTECTED]> wrote:
>
> How could one get only the unique dates from a datetime column, disregarding
> the time part of the datetime object?
MySQL has a DATE() function that chops off the time part. I don't
know if Postgres has the same.
>>> import datetime
>>> import sqlalchemy as sa
>>> e = sa.create_engine("mysql://...")
>>> e.execute("select date('2007-01-20 10:22:45')").fetchone()[0]
datetime.date(2007, 1, 20)
>>> sql = sa.select([sa.func.date('2007-01-20 10:22:45')])
>>> e.execute(sql).fetchone()[0]
datetime.date(2007, 1, 20)
>>> e.execute(sql).fetchone()[0] == datetime.date(2007, 1, 20)
True
--
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---